Handle Half-Life 1 styled point light info

This adds support for the vector version of _light, where the first 3 values are the color and the alpha is the intensity.

Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
Joshua Ashton 2021-08-22 03:10:27 +01:00
parent f68d4836e1
commit fc0e5c3ccc
No known key found for this signature in database
GPG Key ID: C85A08669126BE8D
1 changed files with 23 additions and 8 deletions

View File

@ -542,10 +542,30 @@ void CreateEntityLights( void ){
Sys_FPrintf( SYS_WRN, "WARNING: Styled light found targeting %s\n **", target );
}
/* default to white color values */
light->color[ 0 ] =
light->color[ 1 ] =
light->color[ 2 ] = 1.0f;
/* set light intensity */
intensity = FloatForKey( e, "_light" );
if ( intensity == 0.0f ) {
intensity = FloatForKey( e, "light" );
_color = ValueForKey( e, "_light" );
if ( _color && _color[0] ) {
/* Handle Half-Life styled _light values which
* contain color. Otherwise, fallback to _light
* being a single float for intensity
*/
if ( sscanf( _color, "%f %f %f %f", &light->color[ 0 ], &light->color[ 1 ], &light->color[ 2 ], &intensity ) == 4 ) {
light->color[ 0 ] /= 255;
light->color[ 1 ] /= 255;
light->color[ 2 ] /= 255;
intensity /= 4;
}
else {
intensity = FloatForKey( e, "_light" );
if ( intensity == 0.0f ) {
intensity = FloatForKey( e, "light" );
}
}
}
if ( intensity == 0.0f ) {
intensity = 300.0f;
@ -629,11 +649,6 @@ void CreateEntityLights( void ){
/*if ( !( light->flags & LIGHT_UNNORMALIZED ) ) {
ColorNormalize( light->color, light->color );
}*/
} else {
/* default to white color values */
light->color[ 0 ] =
light->color[ 1 ] =
light->color[ 2 ] = 1.0f;
}
}