diff --git a/include/common/bspfile.hh b/include/common/bspfile.hh index bacb8642..812655db 100644 --- a/include/common/bspfile.hh +++ b/include/common/bspfile.hh @@ -352,6 +352,7 @@ typedef struct { #define TEX_PHONG_ANGLE_CONCAVE_SHIFT 45 #define TEX_PHONG_ANGLE_CONCAVE_MASK (255ULL << TEX_PHONG_ANGLE_CONCAVE_SHIFT) /* 8 bit value. if non zero, overrides _phong_angle for concave joints. */ #define TEX_NOBOUNCE (1ULL << 53) /* light doesn't bounce off this face */ +#define TEX_NOMINLIGHT (1ULL << 54) /* opt out of minlight on this face */ // Q2 Texture flags. #define Q2_SURF_LIGHT 0x1 // value will hold the light strength diff --git a/include/light/light.hh b/include/light/light.hh index 8e937092..80934f6a 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -45,6 +45,9 @@ #define ANGLE_EPSILON 0.001f #define EQUAL_EPSILON 0.001f +// FIXME: use maximum dimension of level +#define MAX_SKY_DIST 1000000.0f + typedef struct { vec3_t color; vec3_t direction; @@ -204,7 +207,6 @@ public: public: lockable_vec_t minlight, shadow, shadowself, shadowworldonly, switchableshadow, switchshadstyle, dirt, phong, phong_angle, alpha; - lockable_string_t minlight_exclude; lockable_vec3_t minlight_color; lockable_bool_t lightignore; @@ -238,7 +240,6 @@ public: phong { "phong", 0 }, phong_angle { "phong_angle", 0 }, alpha { "alpha", 1.0f }, - minlight_exclude { "minlight_exclude", "" }, minlight_color { strings{"minlight_color", "mincolor"}, 255, 255, 255, vec3_transformer_t::NORMALIZE_COLOR_TO_255 }, lightignore { "lightignore", false } { @@ -248,7 +249,7 @@ public: settingsdict_t settings() { return {{ &minlight, &shadow, &shadowself, &shadowworldonly, &switchableshadow, &switchshadstyle, &dirt, &phong, &phong_angle, &alpha, - &minlight_exclude, &minlight_color, &lightignore + &minlight_color, &lightignore }}; } }; diff --git a/include/light/settings.hh b/include/light/settings.hh index f899d0c0..335a37b6 100644 --- a/include/light/settings.hh +++ b/include/light/settings.hh @@ -147,7 +147,8 @@ private: public: bool boolValue() const { - return static_cast(_value); + // we use -1 to mean false + return intValue() == 1; } int intValue() const { diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index 39a0b341..62d350d4 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -141,7 +141,8 @@ #define TEX_PHONG_ANGLE_CONCAVE_SHIFT 45 #define TEX_PHONG_ANGLE_CONCAVE_MASK (255ULL << TEX_PHONG_ANGLE_CONCAVE_SHIFT) /* 8 bit value. if non zero, overrides _phong_angle for concave joints. */ #define TEX_NOBOUNCE (1ULL << 53) /* light doesn't bounce off this face */ -#define TEX_NOEXPAND (1ULL << 54) /* don't expand this face for larger clip hulls */ +#define TEX_NOMINLIGHT (1ULL << 54) /* opt out of minlight on this face */ +#define TEX_NOEXPAND (1ULL << 55) /* don't expand this face for larger clip hulls */ /* * The quality of the bsp output is highly sensitive to these epsilon values. diff --git a/light/bounce.cc b/light/bounce.cc index 0081c62e..d368a148 100644 --- a/light/bounce.cc +++ b/light/bounce.cc @@ -328,8 +328,7 @@ MakeBounceLights (const globalconfig_t &cfg, const mbsp_t *bsp) { logprint("--- MakeBounceLights ---\n"); - const dmodel_t *model = &bsp->dmodels[0]; make_bounce_lights_args_t args { bsp, &cfg }; //mxd. https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.html - RunThreadsOn(model->firstface, model->firstface + model->numfaces, MakeBounceLightsThread, (void *)&args); + RunThreadsOn(0, bsp->numfaces, MakeBounceLightsThread, (void *)&args); } diff --git a/light/ltface.cc b/light/ltface.cc index 9dd8f6af..6ec38c12 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -1530,7 +1530,6 @@ static void LightFace_Sky(const sun_t *sun, const lightsurf_t *lightsurf, lightmapdict_t *lightmaps) { const globalconfig_t &cfg = *lightsurf->cfg; - const float MAX_SKY_DIST = 65536.0f; const modelinfo_t *modelinfo = lightsurf->modelinfo; const plane_t *plane = &lightsurf->plane; @@ -1635,11 +1634,11 @@ LightFace_Min(const mbsp_t *bsp, const bsp2_dface_t *face, const globalconfig_t &cfg = *lightsurf->cfg; const modelinfo_t *modelinfo = lightsurf->modelinfo; - const char *texname = Face_TextureName(bsp, face); - if (texname[0] != '\0' && modelinfo->minlight_exclude.stringValue() == std::string{ texname }) { - return; /* this texture is excluded from minlight */ + const uint64_t extended_flags = extended_texinfo_flags[face->texinfo]; + if ((extended_flags & TEX_NOMINLIGHT) != 0) { + return; /* this face is excluded from minlight */ } - + /* Find a style 0 lightmap */ lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf); diff --git a/light/trace_embree.cc b/light/trace_embree.cc index 6a0a324f..996f8107 100644 --- a/light/trace_embree.cc +++ b/light/trace_embree.cc @@ -37,8 +37,6 @@ using namespace std; using namespace polylib; -static const float MAX_SKY_RAY_DEPTH = 8192.0f; - class sceneinfo { public: unsigned geomID; @@ -754,7 +752,7 @@ qboolean Embree_TestSky(const vec3_t start, const vec3_t dirn, const modelinfo_t VectorCopy(dirn, dir_normalized); VectorNormalize(dir_normalized); - RTCRay ray = SetupRay(0, start, dir_normalized, MAX_SKY_RAY_DEPTH, self); + RTCRay ray = SetupRay(0, start, dir_normalized, MAX_SKY_DIST, self); rtcIntersect(scene, ray); qboolean hit_sky = (ray.geomID == skygeom.geomID); diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 82ba4bf5..e40342e8 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -469,7 +469,7 @@ CreateBrushFaces(hullbrush_t *hullbrush, const vec3_t rotate_offset, // Rotatable objects must have a bounding box big enough to // account for all its rotations - if (rotate_offset[0] || rotate_offset[1] || rotate_offset[2]) { + if (0 /*rotate_offset[0] || rotate_offset[1] || rotate_offset[2]*/) { vec_t delta; delta = fabs(max); diff --git a/qbsp/map.cc b/qbsp/map.cc index 860f0d91..9d108db1 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -310,6 +310,14 @@ FindTexinfoEnt(mtexinfo_t *texinfo, const mapentity_t *entity) flags |= TEX_NODIRT; if (atoi(ValueForKey(entity, "_bounce")) == -1) flags |= TEX_NOBOUNCE; + if (atoi(ValueForKey(entity, "_minlight")) == -1) + flags |= TEX_NOMINLIGHT; + + const char *excludeTex = ValueForKey(entity, "_minlight_exclude"); + if (strlen(excludeTex) > 0 && !Q_strcasecmp(texname, excludeTex)) { + flags |= TEX_NOMINLIGHT; + } + if (shadow == -1) flags |= TEX_NOSHADOW; if (!Q_strcasecmp("func_detail_illusionary", ValueForKey(entity, "classname"))) {