slight speedup by helping embree with alignment
merge some light algorithms together allow changing attenuation on surface lights with _surflight_atten replace some emplace_back's with push_back to improve compilation times
This commit is contained in:
parent
70a08013a7
commit
b5089ce349
|
|
@ -940,7 +940,7 @@ int bsputil_main(int _argc, const char **_argv)
|
|||
|
||||
total_bounds += f.bounds;
|
||||
total_faces += f.faces.size();
|
||||
faces.emplace_back(std::move(f));
|
||||
faces.push_back(std::move(f));
|
||||
};
|
||||
|
||||
addSubModel(0, {});
|
||||
|
|
|
|||
|
|
@ -1771,9 +1771,9 @@ inline void CopyArray(std::vector<F> &from, std::vector<T> &to)
|
|||
|
||||
for (auto &v : from) {
|
||||
if constexpr (std::is_arithmetic_v<T> && std::is_arithmetic_v<F>)
|
||||
to.emplace_back(numeric_cast<T>(v));
|
||||
to.push_back(numeric_cast<T>(v));
|
||||
else
|
||||
to.emplace_back(v);
|
||||
to.push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1794,9 +1794,9 @@ inline void CopyArray(std::vector<std::array<F, N>> &from, std::vector<std::arra
|
|||
|
||||
for (auto &v : from) {
|
||||
if constexpr (std::is_arithmetic_v<T> && std::is_arithmetic_v<F>)
|
||||
to.emplace_back(array_cast<std::array<T, N>>(v));
|
||||
to.push_back(array_cast<std::array<T, N>>(v));
|
||||
else
|
||||
to.emplace_back(v);
|
||||
to.push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ static auto as_tuple(const surfflags_t &flags)
|
|||
return std::tie(flags.native, flags.is_nodraw, flags.is_hintskip, flags.is_hint, flags.no_dirt, flags.no_shadow,
|
||||
flags.no_bounce, flags.no_minlight, flags.no_expand, flags.no_phong, flags.light_ignore,
|
||||
flags.surflight_rescale, flags.surflight_style, flags.surflight_color, flags.surflight_minlight_scale,
|
||||
flags.surflight_atten,
|
||||
flags.surflight_targetname, flags.phong_angle, flags.phong_angle_concave, flags.phong_group, flags.minlight,
|
||||
flags.minlight_color, flags.light_alpha, flags.light_twosided, flags.maxlight, flags.lightcolorscale, flags.surflight_group,
|
||||
flags.world_units_per_luxel, flags.object_channel_mask);
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ full_atlas_t build_lightmap_atlas(const mbsp_t &bsp, const bspxentries_t &bspx,
|
|||
bspx_lmoffset >= faceofs;
|
||||
}
|
||||
|
||||
rectangles.emplace_back(
|
||||
rectangles.push_back(
|
||||
face_rect{&face, get_face_extents(bsp, bspx, bspx_decoupled, face, use_bspx, use_decoupled), faceofs});
|
||||
}
|
||||
|
||||
|
|
@ -850,7 +850,7 @@ void serialize_bsp(const bspdata_t &bspdata, const mbsp_t &bsp, const fs::path &
|
|||
|
||||
if (src_tex.data.size() > sizeof(dmiptex_t)) {
|
||||
json &mips = tex["mips"] = json::array();
|
||||
mips.emplace_back(
|
||||
mips.push_back(
|
||||
serialize_image(img::load_mip(src_tex.name, src_tex.data, false, bspdata.loadversion->game)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -440,10 +440,10 @@ struct decomp_brush_side_t
|
|||
for (auto &face : faces) {
|
||||
auto [faceFront, faceBack] = face.clipToPlane(plane);
|
||||
if (faceFront.winding) {
|
||||
frontfaces.emplace_back(std::move(faceFront));
|
||||
frontfaces.push_back(std::move(faceFront));
|
||||
}
|
||||
if (faceBack.winding) {
|
||||
backfaces.emplace_back(std::move(faceBack));
|
||||
backfaces.push_back(std::move(faceBack));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -633,7 +633,7 @@ static decomp_brush_t BuildInitialBrush(
|
|||
// NOTE: side may have had all of its faces clipped away, but we still need to keep it
|
||||
// as it's one of the final boundaries of the brush
|
||||
|
||||
sides.emplace_back(std::move(side));
|
||||
sides.push_back(std::move(side));
|
||||
}
|
||||
|
||||
return decomp_brush_t(sides);
|
||||
|
|
@ -688,8 +688,7 @@ static decomp_brush_t BuildInitialBrush_Q2(
|
|||
|
||||
auto side = decomp_brush_side_t(bsp, task, plane);
|
||||
side.winding = std::move(*winding);
|
||||
|
||||
sides.emplace_back(side);
|
||||
sides.push_back(std::move(side));
|
||||
}
|
||||
|
||||
return decomp_brush_t(sides);
|
||||
|
|
@ -1093,7 +1092,7 @@ static std::vector<compiled_brush_t> DecompileBrushTask(
|
|||
{
|
||||
for (size_t i = 0; i < task.brush->numsides; i++) {
|
||||
const q2_dbrushside_qbism_t *side = &bsp->dbrushsides[task.brush->firstside + i];
|
||||
decomp_plane_t &plane = task.allPlanes.emplace_back(decomp_plane_t{qplane3d{bsp->dplanes[side->planenum]}});
|
||||
decomp_plane_t &plane = task.allPlanes.emplace_back(qplane3d{bsp->dplanes[side->planenum]});
|
||||
plane.source = side;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1041,7 +1041,7 @@ void brush_t::parse_brush_face(parser_t &parser, texcoord_style_t base_format)
|
|||
|
||||
side.validate_texture_projection();
|
||||
|
||||
faces.emplace_back(std::move(side));
|
||||
faces.push_back(std::move(side));
|
||||
}
|
||||
|
||||
void brush_t::write(std::ostream &stream)
|
||||
|
|
|
|||
|
|
@ -708,7 +708,7 @@ std::vector<std::string> setting_container::parse(parser_base_t &parser)
|
|||
break;
|
||||
}
|
||||
|
||||
remainder.emplace_back(std::move(parser.token));
|
||||
remainder.push_back(std::move(parser.token));
|
||||
}
|
||||
|
||||
return remainder;
|
||||
|
|
|
|||
|
|
@ -267,6 +267,9 @@ struct surfflags_t
|
|||
// surface light rescaling
|
||||
std::optional<float> surflight_minlight_scale;
|
||||
|
||||
// surface light attenuation
|
||||
std::optional<float> surflight_atten;
|
||||
|
||||
// if non zero, enables phong shading and gives the angle threshold to use
|
||||
float phong_angle;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ enum light_formula_t
|
|||
LF_INVERSE2A = 5, /* Inverse square, with distance adjusted to avoid
|
||||
exponentially bright values near the source.
|
||||
(1/(x+128)^2), scaled by 1/(128^2) */
|
||||
LF_QRAD3 = 6, /* qrad3-style surface lights; 1 / (max(x, 16) * max(x, 16)) */
|
||||
LF_COUNT
|
||||
};
|
||||
|
||||
|
|
@ -108,6 +109,7 @@ public:
|
|||
settings::setting_bool nostaticlight;
|
||||
settings::setting_int32 surflight_group;
|
||||
settings::setting_scalar surflight_minlight_scale;
|
||||
settings::setting_scalar surflight_atten;
|
||||
settings::setting_int32 light_channel_mask;
|
||||
settings::setting_int32 shadow_channel_mask;
|
||||
settings::setting_bool nonudge;
|
||||
|
|
|
|||
|
|
@ -225,6 +225,7 @@ public:
|
|||
settings::setting_scalar lightcolorscale;
|
||||
settings::setting_int32 object_channel_mask;
|
||||
settings::setting_scalar surflight_minlight_scale;
|
||||
settings::setting_scalar surflight_atten;
|
||||
settings::setting_bool autominlight;
|
||||
settings::setting_string autominlight_target;
|
||||
|
||||
|
|
@ -315,6 +316,7 @@ public:
|
|||
// "choplight" - arghrad3 name
|
||||
setting_scalar surflightsubdivision;
|
||||
setting_scalar surflight_minlight_scale;
|
||||
setting_scalar surflight_atten;
|
||||
|
||||
/* sunlight */
|
||||
/* sun_light, sun_color, sun_angle for http://www.bspquakeeditor.com/arghrad/ compatibility */
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@ extern std::atomic<uint32_t> total_surflight_rays, total_surflight_ray_hits; //
|
|||
extern std::atomic<uint32_t> fully_transparent_lightmaps; // write.cc
|
||||
|
||||
void PrintFaceInfo(const mface_t *face, const mbsp_t *bsp);
|
||||
// FIXME: remove light param. add normal param and dir params.
|
||||
float GetLightValue(const settings::worldspawn_keys &cfg, const light_t *entity, float dist);
|
||||
void SetupDirt(settings::worldspawn_keys &cfg);
|
||||
lightsurf_t CreateLightmapSurface(const mbsp_t *bsp, const mface_t *face, const facesup_t *facesup,
|
||||
const bspx_decoupled_lm_perface *facesup_decoupled, const settings::worldspawn_keys &cfg);
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ struct surfacelight_t
|
|||
int32_t style = 0; // style ID
|
||||
float intensity = 0; // Surface light strength for each point
|
||||
float totalintensity = 0; // Total surface light strength
|
||||
float atten = 1.0f; // attenuation
|
||||
qvec3f color; // Surface color
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ struct ray_io
|
|||
int dynamic_style = 0;
|
||||
};
|
||||
|
||||
struct alignas(16) aligned_vec3
|
||||
{
|
||||
float x, y, z, w;
|
||||
};
|
||||
|
||||
class raystream_embree_common_t
|
||||
{
|
||||
protected:
|
||||
|
|
@ -114,18 +119,18 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
static inline RTCRayHit SetupRay(unsigned int rayindex, const qvec3f &start, const qvec3f &dir, float dist)
|
||||
static inline RTCRayHit SetupRay(unsigned int rayindex, const aligned_vec3 &start, const aligned_vec3 &dir, float dist)
|
||||
{
|
||||
RTCRayHit ray;
|
||||
ray.ray.org_x = start[0];
|
||||
ray.ray.org_y = start[1];
|
||||
ray.ray.org_z = start[2];
|
||||
ray.ray.tnear = 0.f;
|
||||
ray.ray.org_x = start.x;
|
||||
ray.ray.org_y = start.y;
|
||||
ray.ray.org_z = start.z;
|
||||
ray.ray.tnear = start.w;
|
||||
|
||||
ray.ray.dir_x = dir[0]; // can be un-normalized
|
||||
ray.ray.dir_y = dir[1];
|
||||
ray.ray.dir_z = dir[2];
|
||||
ray.ray.time = 0.f; // not using
|
||||
ray.ray.dir_x = dir.x; // can be un-normalized
|
||||
ray.ray.dir_y = dir.y;
|
||||
ray.ray.dir_z = dir.z;
|
||||
ray.ray.time = dir.w; // not using
|
||||
|
||||
ray.ray.tfar = dist;
|
||||
ray.ray.mask = 1; // we're not using, but needs to be set if embree is compiled with masks
|
||||
|
|
@ -217,8 +222,8 @@ public:
|
|||
inline void pushRay(int i, const qvec3f &origin, const qvec3f &dir, float dist, const qvec3f *color = nullptr,
|
||||
const qvec3f *normalcontrib = nullptr)
|
||||
{
|
||||
const RTCRayHit rayHit = SetupRay(_rays.size(), origin, dir, dist);
|
||||
_rays.emplace_back(
|
||||
const RTCRayHit rayHit = SetupRay(_rays.size(), { origin[0], origin[1], origin[2], 0.f }, { dir[0], dir[1], dir[2], 0.f }, dist);
|
||||
_rays.push_back(
|
||||
ray_io {
|
||||
.ray = rayHit,
|
||||
.maxdist = dist,
|
||||
|
|
@ -285,8 +290,8 @@ public:
|
|||
inline void pushRay(int i, const qvec3f &origin, const qvec3f &dir, float dist, const qvec3f *color = nullptr,
|
||||
const qvec3f *normalcontrib = nullptr)
|
||||
{
|
||||
const RTCRay ray = SetupRay(_rays.size(), origin, dir, dist).ray;
|
||||
_rays.emplace_back(
|
||||
const RTCRay ray = SetupRay(_rays.size(), { origin[0], origin[1], origin[2], 0.f }, { dir[0], dir[1], dir[2], 0.f }, dist).ray;
|
||||
_rays.push_back(
|
||||
ray_io {
|
||||
.ray = { ray },
|
||||
.maxdist = dist,
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ light_t::light_t()
|
|||
nostaticlight{this, "nostaticlight", false},
|
||||
surflight_group{this, "surflight_group", 0},
|
||||
surflight_minlight_scale{this, "surflight_minlight_scale", 1.f},
|
||||
surflight_atten{this, "surflight_atten", 1.f},
|
||||
light_channel_mask{this, "light_channel_mask", CHANNEL_MASK_DEFAULT},
|
||||
shadow_channel_mask{this, "shadow_channel_mask", CHANNEL_MASK_DEFAULT},
|
||||
nonudge{this, "nonudge", false}
|
||||
|
|
@ -359,6 +360,12 @@ static void CheckEntityFields(const mbsp_t *bsp, const settings::worldspawn_keys
|
|||
entity->surflight_minlight_scale.set_value(64.0f, settings::source::DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
if (!entity->surflight_atten.is_changed()) {
|
||||
if (cfg.surflight_atten.is_changed()) {
|
||||
entity->surflight_atten.set_value(cfg.surflight_atten.value(), settings::source::DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ modelinfo_t::modelinfo_t(const mbsp_t *b, const dmodelh2_t *m, float lmscale)
|
|||
lightcolorscale{this, "lightcolorscale", 1},
|
||||
object_channel_mask{this, "object_channel_mask", CHANNEL_MASK_DEFAULT},
|
||||
surflight_minlight_scale{this, "surflight_minlight_scale", 1.f},
|
||||
surflight_atten{this, "surflight_atten", 1.f},
|
||||
autominlight{this, "autominlight", false},
|
||||
autominlight_target{this, "autominlight_target", ""}
|
||||
{
|
||||
|
|
@ -195,6 +196,7 @@ worldspawn_keys::worldspawn_keys()
|
|||
surflightskydist{this, "surflightskydist", 0.0, &worldspawn_group},
|
||||
surflightsubdivision{this, {"surflightsubdivision", "choplight"}, 16.0, 1.0, 8192.0, &worldspawn_group},
|
||||
surflight_minlight_scale{this, "surflight_minlight_scale", 1.0f, 0.f, 510.f, &worldspawn_group},
|
||||
surflight_atten{this, "surflight_atten", 1.f, 0.f, std::numeric_limits<float>::max(), &worldspawn_group},
|
||||
sunlight{this, {"sunlight", "sun_light"}, 0.0, &worldspawn_group},
|
||||
sunlight_color{this, {"sunlight_color", "sun_color"}, 255.0, 255.0, 255.0, &worldspawn_group},
|
||||
sun2{this, "sun2", 0.0, &worldspawn_group},
|
||||
|
|
@ -1036,6 +1038,9 @@ static void LoadExtendedTexinfoFlags(const fs::path &sourcefilename, const mbsp_
|
|||
if (val.contains("surflight_minlight_scale")) {
|
||||
flags.surflight_minlight_scale = val.at("surflight_minlight_scale").get<float>();
|
||||
}
|
||||
if (val.contains("surflight_atten")) {
|
||||
flags.surflight_atten = val.at("surflight_atten").get<float>();
|
||||
}
|
||||
if (val.contains("phong_angle")) {
|
||||
flags.phong_angle = val.at("phong_angle").get<float>();
|
||||
}
|
||||
|
|
@ -1072,9 +1077,6 @@ static void LoadExtendedTexinfoFlags(const fs::path &sourcefilename, const mbsp_
|
|||
if (val.contains("object_channel_mask")) {
|
||||
flags.object_channel_mask = val.at("object_channel_mask").get<int32_t>();
|
||||
}
|
||||
if (val.contains("surflight_minlight_scale")) {
|
||||
flags.surflight_minlight_scale = val.at("surflight_minlight_scale").get<float>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -805,44 +805,58 @@ static void Lightmap_Save(
|
|||
*/
|
||||
|
||||
// returns the light contribution at a given distance, without regard for angle
|
||||
float GetLightValue(const settings::worldspawn_keys &cfg, const light_t *entity, float dist)
|
||||
static float GetLightValue(const settings::worldspawn_keys &cfg,
|
||||
const light_formula_t formula, const float light, const float falloff,
|
||||
const float atten, const float dist, const float hotspot_clamp)
|
||||
{
|
||||
const float light = entity->light.value();
|
||||
if (formula == LF_INFINITE || formula == LF_LOCALMIN)
|
||||
return light;
|
||||
|
||||
// mxd. Apply falloff?
|
||||
const float lightdistance = entity->falloff.value();
|
||||
if (lightdistance > 0.0f) {
|
||||
if (entity->getFormula() == LF_LINEAR) {
|
||||
if (falloff > 0.0f) {
|
||||
if (formula == LF_LINEAR) {
|
||||
// Light can affect surface?
|
||||
if (lightdistance > dist)
|
||||
return light * (1.0f - (dist / lightdistance));
|
||||
if (falloff > dist)
|
||||
return light * (1.0f - (dist / falloff));
|
||||
else
|
||||
return 0.0f; // Surface is unaffected
|
||||
}
|
||||
}
|
||||
|
||||
if (entity->getFormula() == LF_INFINITE || entity->getFormula() == LF_LOCALMIN)
|
||||
return light;
|
||||
float value = cfg.scaledist.value() * atten * dist;
|
||||
|
||||
float value = cfg.scaledist.value() * entity->atten.value() * dist;
|
||||
|
||||
switch (entity->getFormula()) {
|
||||
case LF_INVERSE: return light / (value / LF_SCALE);
|
||||
switch (formula) {
|
||||
case LF_INVERSE: return light / (value / hotspot_clamp);
|
||||
case LF_INVERSE2A:
|
||||
value += LF_SCALE;
|
||||
value += hotspot_clamp;
|
||||
/* Fall through */
|
||||
case LF_INVERSE2: return light / ((value * value) / (LF_SCALE * LF_SCALE));
|
||||
case LF_INVERSE2: return light / ((value * value) / (hotspot_clamp * hotspot_clamp));
|
||||
case LF_LINEAR:
|
||||
if (light > 0)
|
||||
return (light - value > 0) ? light - value : 0;
|
||||
else
|
||||
return (light + value < 0) ? light + value : 0;
|
||||
case LF_QRAD3: {
|
||||
const float d = std::max(value, hotspot_clamp); // Clamp away hotspots, also avoid division by 0...
|
||||
return light / (d * d);
|
||||
}
|
||||
default: Error("Internal error: unknown light formula");
|
||||
}
|
||||
}
|
||||
|
||||
static float GetLightValueWithAngle(const settings::worldspawn_keys &cfg, const light_t *entity, const qvec3f &surfnorm,
|
||||
bool use_surfnorm, const qvec3f &surfpointToLightDir, float dist, bool twosided)
|
||||
// mxd. Surface light falloff. Returns color in [0,255]
|
||||
inline qvec3f SurfaceLight_ColorAtDist(const settings::worldspawn_keys &cfg, const float &surf_scale,
|
||||
const float &intensity, const qvec3f &color, const float &dist, const float &atten, const float &hotspot_clamp)
|
||||
{
|
||||
const float v = GetLightValue(cfg, LF_QRAD3, intensity, 0.0f, atten, dist, hotspot_clamp) * surf_scale;
|
||||
return color * v;
|
||||
}
|
||||
|
||||
static float GetLightValueWithAngle(const settings::worldspawn_keys &cfg,
|
||||
const light_formula_t formula, const float light, const float falloff,
|
||||
const float atten, const bool bleed, const float anglescale, const qvec3f &surfnorm,
|
||||
bool use_surfnorm, const qvec3f &surfpointToLightDir, const float dist, bool twosided,
|
||||
const float hotspot_clamp)
|
||||
{
|
||||
float angle;
|
||||
|
||||
|
|
@ -852,7 +866,7 @@ static float GetLightValueWithAngle(const settings::worldspawn_keys &cfg, const
|
|||
angle = 1.0f;
|
||||
}
|
||||
|
||||
if (entity->bleed.value() || twosided) {
|
||||
if (bleed || twosided) {
|
||||
if (angle < 0) {
|
||||
angle = -angle; // ericw -- support "_bleed" option
|
||||
}
|
||||
|
|
@ -865,7 +879,21 @@ static float GetLightValueWithAngle(const settings::worldspawn_keys &cfg, const
|
|||
}
|
||||
|
||||
/* Apply anglescale */
|
||||
angle = (1.0 - entity->anglescale.value()) + (entity->anglescale.value() * angle);
|
||||
angle = (1.0 - anglescale) + (anglescale * angle);
|
||||
|
||||
return GetLightValue(cfg, formula, light, falloff, atten, dist, hotspot_clamp) * angle;
|
||||
}
|
||||
|
||||
// returns the light contribution at a given distance, without regard for angle
|
||||
static float GetLightValue(const settings::worldspawn_keys &cfg, const light_t *entity, const float dist)
|
||||
{
|
||||
return GetLightValue(cfg, entity->getFormula(), entity->light.value(), entity->falloff.value(), entity->atten.value(), dist, LF_SCALE);
|
||||
}
|
||||
|
||||
static float GetLightValueWithAngle(const settings::worldspawn_keys &cfg, const light_t *entity, const qvec3f &surfnorm,
|
||||
bool use_surfnorm, const qvec3f &surfpointToLightDir, float dist, bool twosided)
|
||||
{
|
||||
float value = GetLightValue(cfg, entity, dist);
|
||||
|
||||
/* Check spotlight cone */
|
||||
float spotscale = 1;
|
||||
|
|
@ -883,8 +911,7 @@ static float GetLightValueWithAngle(const settings::worldspawn_keys &cfg, const
|
|||
}
|
||||
}
|
||||
|
||||
float add = GetLightValue(cfg, entity, dist) * angle * spotscale;
|
||||
return add;
|
||||
return value * spotscale;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -1902,18 +1929,6 @@ static void LightFace_DebugMottle(const mbsp_t *bsp, const lightsurf_t *lightsur
|
|||
Lightmap_Save(bsp, lightmaps, lightsurf, lightmap, 0);
|
||||
}
|
||||
|
||||
// mxd. Surface light falloff. Returns color in [0,255]
|
||||
constexpr qvec3f SurfaceLight_ColorAtDist(const settings::worldspawn_keys &cfg, const float &surf_scale,
|
||||
const float &intensity, const qvec3f &color, const float &dist, const float &hotspot_clamp)
|
||||
{
|
||||
// Exponential falloff
|
||||
const float d = std::max(dist, hotspot_clamp); // Clamp away hotspots, also avoid division by 0...
|
||||
const float scaledintensity = intensity * surf_scale;
|
||||
const float scale = (1.0f / (d * d));
|
||||
|
||||
return color * scaledintensity * scale;
|
||||
}
|
||||
|
||||
// dir: vpl -> sample point direction
|
||||
// mxd. returns color in [0,255]
|
||||
inline qvec3f GetSurfaceLighting(const settings::worldspawn_keys &cfg, const surfacelight_t &vpl,
|
||||
|
|
@ -1957,14 +1972,8 @@ inline qvec3f GetSurfaceLighting(const settings::worldspawn_keys &cfg, const sur
|
|||
}
|
||||
|
||||
// Get light contribution
|
||||
result = SurfaceLight_ColorAtDist(cfg, vpl_settings.omnidirectional ? sky_scale : standard_scale,
|
||||
vpl_settings.intensity, vpl_settings.color, dist, hotspot_clamp);
|
||||
|
||||
// Apply angle scale
|
||||
const qvec3f resultscaled = result * dotProductFactor;
|
||||
|
||||
//Q_assert(!std::isnan(resultscaled[0]) && !std::isnan(resultscaled[1]) && !std::isnan(resultscaled[2]));
|
||||
return resultscaled;
|
||||
return SurfaceLight_ColorAtDist(cfg, (vpl_settings.omnidirectional ? sky_scale : standard_scale) * dotProductFactor,
|
||||
vpl_settings.intensity, vpl_settings.color, dist, vpl_settings.atten, hotspot_clamp);
|
||||
}
|
||||
|
||||
static bool // mxd
|
||||
|
|
@ -1985,7 +1994,7 @@ SurfaceLight_SphereCull(const surfacelight_t *vpl, const lightsurf_t *lightsurf,
|
|||
// Get light contribution
|
||||
const qvec3f color = SurfaceLight_ColorAtDist(cfg,
|
||||
vpl_settings.omnidirectional ? cfg.surflightskyscale.value() : cfg.surflightscale.value(),
|
||||
vpl_settings.totalintensity, vpl_settings.color, dist, hotspot_clamp);
|
||||
vpl_settings.totalintensity, vpl_settings.color, dist, vpl_settings.atten, hotspot_clamp);
|
||||
|
||||
return qv::gate(color, (float)bouncelight_gate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,6 +203,9 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys
|
|||
setting.totalintensity = intensity * facearea;
|
||||
setting.intensity = setting.totalintensity / l->points_before_culling;
|
||||
setting.color = texture_color.value();
|
||||
if (extended_flags.surflight_atten.has_value()) {
|
||||
setting.atten = extended_flags.surflight_atten.value();
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::tuple<int32_t, int32_t, qvec3f, light_t *>> IsSurfaceLitFace(const mbsp_t *bsp, const mface_t *face)
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ inline int64_t GetEdge(const size_t &v1, const size_t &v2, const face_t *face, e
|
|||
/* emit an edge */
|
||||
int64_t i = map.bsp.dedges.size();
|
||||
|
||||
map.bsp.dedges.emplace_back(bsp2_dedge_t{static_cast<uint32_t>(v1), static_cast<uint32_t>(v2)});
|
||||
map.bsp.dedges.push_back(bsp2_dedge_t{static_cast<uint32_t>(v1), static_cast<uint32_t>(v2)});
|
||||
|
||||
map.add_hash_edge(v1, v2, i, face);
|
||||
|
||||
|
|
|
|||
15
qbsp/map.cc
15
qbsp/map.cc
|
|
@ -573,7 +573,7 @@ int FindTexinfo(const maptexinfo_t &texinfo, const qplane3d &plane, bool add)
|
|||
|
||||
/* Allocate a new texinfo at the end of the array */
|
||||
const int num_texinfo = static_cast<int>(map.mtexinfos.size());
|
||||
map.mtexinfos.emplace_back(texinfo);
|
||||
map.mtexinfos.push_back(texinfo);
|
||||
map.mtexinfo_lookup[texinfo] = num_texinfo;
|
||||
|
||||
// catch broken < implementations in maptexinfo_t
|
||||
|
|
@ -687,6 +687,13 @@ static surfflags_t SurfFlagsForEntity(
|
|||
map.world_entity().epairs.has("_surflight_minlight_scale"))
|
||||
flags.surflight_minlight_scale = map.world_entity().epairs.get_float("_surflight_minlight_scale");
|
||||
|
||||
if (entity.epairs.has("_surflight_atten"))
|
||||
flags.surflight_atten = entity.epairs.get_float("_surflight_atten");
|
||||
// Paril: inherit _surflight_atten from worldspawn if unset
|
||||
else if (!entity.epairs.has("_surflight_atten") &&
|
||||
map.world_entity().epairs.has("_surflight_atten"))
|
||||
flags.surflight_atten = map.world_entity().epairs.get_float("_surflight_atten");
|
||||
|
||||
// "_minlight_exclude", "_minlight_exclude2", "_minlight_exclude3"...
|
||||
for (int i = 0; i <= 9; i++) {
|
||||
std::string key = "_minlight_exclude";
|
||||
|
|
@ -1616,7 +1623,7 @@ static mapbrush_t ParseBrush(const mapfile::brush_t &in, mapentity_t &entity, te
|
|||
new_side.planenum = map.add_or_find_plane(
|
||||
{new_side.get_plane().get_normal(), new_side.get_plane().get_dist() + 16.f});
|
||||
|
||||
new_brush.faces.emplace_back(std::move(new_side));
|
||||
new_brush.faces.push_back(std::move(new_side));
|
||||
// the inverted side is special
|
||||
} else if (side.get_plane().get_normal() == -new_brush_side.get_plane().get_normal()) {
|
||||
|
||||
|
|
@ -1629,7 +1636,7 @@ static mapbrush_t ParseBrush(const mapfile::brush_t &in, mapentity_t &entity, te
|
|||
flipped_side.planenum = map.add_or_find_plane(
|
||||
{-new_brush_side.get_plane().get_normal(), -new_brush_side.get_plane().get_dist()});
|
||||
|
||||
new_brush.faces.emplace_back(std::move(flipped_side));
|
||||
new_brush.faces.push_back(std::move(flipped_side));
|
||||
} else {
|
||||
mapface_t new_side;
|
||||
new_side.texinfo = side.texinfo;
|
||||
|
|
@ -1638,7 +1645,7 @@ static mapbrush_t ParseBrush(const mapfile::brush_t &in, mapentity_t &entity, te
|
|||
new_side.texname = side.texname;
|
||||
new_side.planenum = side.planenum;
|
||||
|
||||
new_brush.faces.emplace_back(std::move(new_side));
|
||||
new_brush.faces.push_back(std::move(new_side));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ void MergeFaceToList(
|
|||
}
|
||||
}
|
||||
|
||||
list.emplace_back(std::move(face));
|
||||
list.push_back(std::move(face));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ static std::list<std::vector<size_t>> compress_triangles_into_fans(
|
|||
// just add the rest directly.
|
||||
if (fan.size() == 1) {
|
||||
for (auto &tri : triangles) {
|
||||
tris_compiled.emplace_back(std::vector<size_t>{vertices[tri[0]], vertices[tri[1]], vertices[tri[2]]});
|
||||
tris_compiled.push_back(std::vector<size_t>{vertices[tri[0]], vertices[tri[1]], vertices[tri[2]]});
|
||||
}
|
||||
|
||||
triangles.clear();
|
||||
|
|
@ -564,7 +564,7 @@ static std::vector<qvectri> minimum_weight_triangulation(
|
|||
|
||||
qvectri tri{edge[0], edge[1], c.value()};
|
||||
std::sort(tri.begin(), tri.end());
|
||||
triangles.emplace_back(tri);
|
||||
triangles.push_back(tri);
|
||||
|
||||
edge_queue.emplace(edge[0], c.value());
|
||||
edge_queue.emplace(c.value(), edge[1]);
|
||||
|
|
@ -710,7 +710,7 @@ static std::list<std::vector<size_t>> RetopologizeFace(const face_t *f, const st
|
|||
break;
|
||||
}
|
||||
|
||||
tri.emplace_back(input[x]);
|
||||
tri.push_back(input[x]);
|
||||
x = (x + 1) % input.size();
|
||||
first = false;
|
||||
}
|
||||
|
|
@ -766,7 +766,7 @@ static void FixFaceEdges(node_t *headnode, face_t *f, tjunc_stats_t &stats)
|
|||
{
|
||||
// we were asked not to bother fixing any of the faces.
|
||||
if (qbsp_options.tjunc.value() == settings::tjunclevel_t::NONE) {
|
||||
f->fragments.emplace_back(face_fragment_t{f->original_vertices});
|
||||
f->fragments.push_back(face_fragment_t{f->original_vertices});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -778,7 +778,7 @@ static void FixFaceEdges(node_t *headnode, face_t *f, tjunc_stats_t &stats)
|
|||
return;
|
||||
} else if (superface.size() == 3) {
|
||||
// no need to adjust this either
|
||||
f->fragments.emplace_back(face_fragment_t{f->original_vertices});
|
||||
f->fragments.push_back(face_fragment_t{f->original_vertices});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -854,7 +854,7 @@ static void FixFaceEdges(node_t *headnode, face_t *f, tjunc_stats_t &stats)
|
|||
// the other techniques all failed, or we asked to not
|
||||
// try them. just move the superface in directly.
|
||||
if (!faces.size()) {
|
||||
faces.emplace_back(std::move(superface));
|
||||
faces.push_back(std::move(superface));
|
||||
}
|
||||
|
||||
Q_assert(faces.size());
|
||||
|
|
@ -872,7 +872,7 @@ static void FixFaceEdges(node_t *headnode, face_t *f, tjunc_stats_t &stats)
|
|||
f->fragments.reserve(faces.size());
|
||||
|
||||
for (auto &face : faces) {
|
||||
f->fragments.emplace_back(face_fragment_t{std::move(face)});
|
||||
f->fragments.push_back(face_fragment_t{std::move(face)});
|
||||
}
|
||||
|
||||
for (auto &frag : f->fragments) {
|
||||
|
|
|
|||
|
|
@ -414,6 +414,9 @@ static void WriteExtendedTexinfoFlags()
|
|||
if (tx.flags.surflight_minlight_scale.has_value()) {
|
||||
t["surflight_minlight_scale"] = tx.flags.surflight_minlight_scale.value();
|
||||
}
|
||||
if (tx.flags.surflight_atten.has_value()) {
|
||||
t["surflight_atten"] = tx.flags.surflight_atten.value();
|
||||
}
|
||||
if (tx.flags.phong_angle) {
|
||||
t["phong_angle"] = tx.flags.phong_angle;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue