light: add _spotlightautofalloff
This commit is contained in:
parent
604aa92e6f
commit
15871d2531
|
|
@ -261,6 +261,7 @@ public:
|
|||
lockable_bool_t addminlight;
|
||||
lockable_vec_t minlight;
|
||||
lockable_vec3_t minlight_color;
|
||||
lockable_bool_t spotlightautofalloff; //mxd
|
||||
|
||||
/* dirt */
|
||||
lockable_bool_t globalDirt; // apply dirt to all lights (unless they override it) + sunlight + minlight?
|
||||
|
|
@ -301,6 +302,7 @@ public:
|
|||
addminlight {"addmin", false},
|
||||
minlight {strings{"light", "minlight"}, 0},
|
||||
minlight_color {strings{"minlight_color", "mincolor"}, 255.0f, 255.0f, 255.0f, vec3_transformer_t::NORMALIZE_COLOR_TO_255},
|
||||
spotlightautofalloff { "spotlightautofalloff", false }, //mxd
|
||||
|
||||
/* dirt */
|
||||
globalDirt {strings{"dirt", "dirty"}, false},
|
||||
|
|
@ -342,6 +344,7 @@ public:
|
|||
&addminlight,
|
||||
&minlight,
|
||||
&minlight_color,
|
||||
&spotlightautofalloff, //mxd
|
||||
&globalDirt,
|
||||
&dirtMode, &dirtDepth, &dirtScale, &dirtGain, &dirtAngle,
|
||||
&minlightDirt,
|
||||
|
|
|
|||
|
|
@ -292,13 +292,15 @@ EntDict_CheckTargetnameKeyMatched(const bsp2_t *bsp, const entdict_t &entity, co
|
|||
}
|
||||
|
||||
static void
|
||||
SetupSpotlights(void)
|
||||
SetupSpotlights(const globalconfig_t &cfg)
|
||||
{
|
||||
for (light_t &entity : all_lights) {
|
||||
float targetdist; //mxd
|
||||
if (entity.targetent) {
|
||||
vec3_t targetOrigin;
|
||||
EntDict_VectorForKey(*entity.targetent, "origin", targetOrigin);
|
||||
VectorSubtract(targetOrigin, *entity.origin.vec3Value(), entity.spotvec);
|
||||
targetdist = VectorLength(entity.spotvec); //mxd
|
||||
VectorNormalize(entity.spotvec);
|
||||
entity.spotlight = true;
|
||||
}
|
||||
|
|
@ -312,6 +314,12 @@ SetupSpotlights(void)
|
|||
if (angle2 <= 0 || angle2 > angle)
|
||||
angle2 = angle;
|
||||
entity.spotfalloff2 = -cos(angle2 / 2 * Q_PI / 180);
|
||||
|
||||
//mxd. Apply autofalloff?
|
||||
if(entity.falloff.floatValue() == 0 && cfg.spotlightautofalloff.boolValue()) {
|
||||
float coneradius = targetdist * tan(angle / 2 * Q_PI / 180);
|
||||
entity.falloff.setFloatValue(targetdist + coneradius);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1253,7 +1261,7 @@ SetupLights(const globalconfig_t &cfg, const bsp2_t *bsp)
|
|||
const size_t final_lightcount = all_lights.size();
|
||||
|
||||
MatchTargets();
|
||||
SetupSpotlights();
|
||||
SetupSpotlights(cfg);
|
||||
SetupSuns(cfg);
|
||||
SetupSkyDome(cfg);
|
||||
FixLightsOnFaces(bsp);
|
||||
|
|
|
|||
|
|
@ -221,6 +221,9 @@ Weight for bounce lighting to use texture colors from the map: 0=ignore map text
|
|||
.IP "\fB""_bouncestyled"" ""n""\fP"
|
||||
1 makes styled lights bounce (e.g. flickering or switchable lights), default is 0, they do not bounce.
|
||||
|
||||
.IP "\fB""_spotlightautofalloff"" ""n""\fP"
|
||||
When set to 1, spotlight falloff is calculated from the distance to the targeted info_null. Ignored when "_falloff" is not 0. Default 0.
|
||||
|
||||
|
||||
.SS "Model Entity Keys"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue