diff --git a/light/entities.c b/light/entities.c index abfc4c66..54231dce 100644 --- a/light/entities.c +++ b/light/entities.c @@ -1029,7 +1029,7 @@ WriteEntitiesToString(bsp2_t *bsp) * ======================================================================= */ -static void CreateSurfaceLight(const vec3_t origin, const entity_t *surflight_template) +static void CreateSurfaceLight(const vec3_t origin, const vec3_t normal, const entity_t *surflight_template) { entity_t *entity = DuplicateEntity(surflight_template); @@ -1038,6 +1038,12 @@ static void CreateSurfaceLight(const vec3_t origin, const entity_t *surflight_te /* don't write to bsp */ entity->generated = true; + /* set spotlight vector based on face normal */ + if (atoi(ValueForKey(surflight_template, "_surface_spotlight"))) { + entity->spotlight = true; + VectorCopy(normal, entity->spotvec); + } + num_lights++; } @@ -1070,7 +1076,7 @@ static void CreateSurfaceLightOnFaceSubdivision(const bsp2_dface_t *face, const VectorMA(midpoint, offset, normal, midpoint); - CreateSurfaceLight(midpoint, surflight_template); + CreateSurfaceLight(midpoint, normal, surflight_template); } static void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs) diff --git a/man/light.1 b/man/light.1 index 0aa2ad2f..39757ae5 100644 --- a/man/light.1 +++ b/man/light.1 @@ -264,6 +264,12 @@ Z-axis from 0 to 359 degrees and pitch specifies the angle from 90 (straight up) to -90 (straight down). Roll has no effect, so use any value (e.g. 0). Often easier than the "target" method. +.IP "\fB""_surface_spotlight"" ""n""\fP" +For a surface light template (i.e. a light with "_surface" set), setting this to +"1" makes each instance into a spotlight, with the direction of light +pointing along the surface normal. In other words, it automatically sets +"mangle" on each of the generated lights. + .IP "\fB""angle"" ""n""\fP" Specifies the angle in degrees for a spotlight cone. Default 40.