2004-08-22 22:29:09 +00:00
/*
Copyright ( C ) 1996 - 1997 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
// r_light.c
# include "quakedef.h"
2016-07-12 00:40:13 +00:00
# ifndef SERVERONLY
2004-08-22 22:29:09 +00:00
# include "glquake.h"
2010-03-26 02:17:55 +00:00
# include "shader.h"
2011-10-27 16:16:29 +00:00
extern cvar_t r_shadow_realtime_world , r_shadow_realtime_world_lightmaps ;
2015-04-27 12:51:42 +00:00
extern cvar_t r_hdr_irisadaptation , r_hdr_irisadaptation_multiplier , r_hdr_irisadaptation_minvalue , r_hdr_irisadaptation_maxvalue , r_hdr_irisadaptation_fade_down , r_hdr_irisadaptation_fade_up ;
2022-01-08 09:59:54 +00:00
extern cvar_t mod_lightpoint_distance ;
2011-10-27 16:16:29 +00:00
2004-08-22 22:29:09 +00:00
int r_dlightframecount ;
2019-09-10 15:40:04 +00:00
int d_lightstylevalue [ MAX_NET_LIGHTSTYLES ] ; // 8.8 fraction of base light value
2004-08-22 22:29:09 +00:00
2019-09-10 15:40:04 +00:00
void R_BumpLightstyles ( unsigned int maxstyle )
{
int style = cl_max_lightstyles ;
if ( maxstyle > = style )
{
Z_ReallocElements ( ( void * * ) & cl_lightstyle , & cl_max_lightstyles , maxstyle + 1 , sizeof ( * cl_lightstyle ) ) ;
for ( ; style < cl_max_lightstyles ; style + + )
VectorSet ( cl_lightstyle [ style ] . colours , 1 , 1 , 1 ) ;
}
}
2014-06-25 03:53:11 +00:00
void R_UpdateLightStyle ( unsigned int style , const char * stylestring , float r , float g , float b )
{
2019-09-10 15:40:04 +00:00
if ( style > = MAX_NET_LIGHTSTYLES )
2014-06-25 03:53:11 +00:00
return ;
2019-09-10 15:40:04 +00:00
R_BumpLightstyles ( style ) ;
2014-06-25 03:53:11 +00:00
if ( ! stylestring )
stylestring = " " ;
Q_strncpyz ( cl_lightstyle [ style ] . map , stylestring , sizeof ( cl_lightstyle [ style ] . map ) ) ;
cl_lightstyle [ style ] . length = Q_strlen ( cl_lightstyle [ style ] . map ) ;
if ( ! cl_lightstyle [ style ] . length )
{
d_lightstylevalue [ style ] = 256 ;
VectorSet ( cl_lightstyle [ style ] . colours , 1 , 1 , 1 ) ;
}
else
VectorSet ( cl_lightstyle [ style ] . colours , r , g , b ) ;
cl_lightstyle [ style ] . colourkey = ( int ) ( cl_lightstyle [ style ] . colours [ 0 ] * 0x400 ) ^ ( int ) ( cl_lightstyle [ style ] . colours [ 1 ] * 0x100000 ) ^ ( int ) ( cl_lightstyle [ style ] . colours [ 2 ] * 0x40000000 ) ;
}
2015-04-27 12:51:42 +00:00
void Sh_CalcPointLight ( vec3_t point , vec3_t light ) ;
void R_UpdateHDR ( vec3_t org )
{
if ( r_hdr_irisadaptation . ival & & cl . worldmodel & & ! ( r_refdef . flags & RDF_NOWORLDMODEL ) )
{
//fake and lame, but whatever.
vec3_t ambient , diffuse , dir ;
float lev = 0 ;
2015-04-27 12:55:48 +00:00
# ifdef RTLIGHTS
Sh_CalcPointLight ( org , ambient ) ;
lev + = VectorLength ( ambient ) ;
2015-04-27 12:51:42 +00:00
if ( ! r_shadow_realtime_world . ival | | r_shadow_realtime_world_lightmaps . value )
2015-04-27 12:55:48 +00:00
# endif
2015-04-27 12:51:42 +00:00
{
cl . worldmodel - > funcs . LightPointValues ( cl . worldmodel , org , ambient , diffuse , dir ) ;
lev + = ( VectorLength ( ambient ) + VectorLength ( diffuse ) ) / 256 ;
}
lev + = 0.001 ; //no division by 0!
lev = r_hdr_irisadaptation_multiplier . value / lev ;
lev = bound ( r_hdr_irisadaptation_minvalue . value , lev , r_hdr_irisadaptation_maxvalue . value ) ;
if ( lev > r_refdef . playerview - > hdr_last + r_hdr_irisadaptation_fade_up . value * host_frametime )
lev = r_refdef . playerview - > hdr_last + r_hdr_irisadaptation_fade_up . value * host_frametime ;
else if ( lev < r_refdef . playerview - > hdr_last - r_hdr_irisadaptation_fade_down . value * host_frametime )
lev = r_refdef . playerview - > hdr_last - r_hdr_irisadaptation_fade_down . value * host_frametime ;
lev = bound ( r_hdr_irisadaptation_minvalue . value , lev , r_hdr_irisadaptation_maxvalue . value ) ;
r_refdef . playerview - > hdr_last = lev ;
r_refdef . hdr_value = lev ;
}
else
r_refdef . hdr_value = 1 ;
}
2004-08-22 22:29:09 +00:00
/*
= = = = = = = = = = = = = = = = = =
R_AnimateLight
= = = = = = = = = = = = = = = = = =
*/
2009-11-04 21:16:50 +00:00
void R_AnimateLight ( void )
2004-08-22 22:29:09 +00:00
{
2005-06-22 17:10:13 +00:00
int i , j ;
float f ;
2020-04-29 10:43:22 +00:00
static int fbmodcount ;
2015-04-14 23:12:17 +00:00
2015-04-27 12:51:42 +00:00
2015-04-14 23:12:17 +00:00
//if (r_lightstylescale.value > 2)
//r_lightstylescale.value = 2;
2004-08-22 22:29:09 +00:00
//
// light animations
// 'm' is normal light, 'a' is no light, 'z' is double bright
2005-06-22 17:10:13 +00:00
f = ( cl . time * r_lightstylespeed . value ) ;
if ( f < 0 )
f = 0 ;
i = ( int ) f ;
2011-04-20 23:05:45 +00:00
f - = i ; //this can require updates at 1000 times a second.. Depends on your framerate of course
2005-06-22 17:10:13 +00:00
2020-04-29 10:43:22 +00:00
if ( r_fullbright . value )
{
for ( j = 0 ; j < cl_max_lightstyles ; j + + )
d_lightstylevalue [ j ] = r_fullbright . value * 255 ;
}
else for ( j = 0 ; j < cl_max_lightstyles ; j + + )
2004-08-22 22:29:09 +00:00
{
2011-04-20 23:05:45 +00:00
int v1 , v2 , vd ;
2004-08-22 22:29:09 +00:00
if ( ! cl_lightstyle [ j ] . length )
2014-10-11 19:39:45 +00:00
{
2015-04-14 23:12:17 +00:00
d_lightstylevalue [ j ] = ( ' m ' - ' a ' ) * 22 * r_lightstylescale . value ;
2004-08-22 22:29:09 +00:00
continue ;
2014-10-11 19:39:45 +00:00
}
2014-06-25 03:53:11 +00:00
2014-10-05 20:04:11 +00:00
if ( cl_lightstyle [ j ] . map [ 0 ] = = ' = ' )
{
2015-04-14 23:12:17 +00:00
d_lightstylevalue [ j ] = atof ( cl_lightstyle [ j ] . map + 1 ) * 256 * r_lightstylescale . value ;
2014-10-05 20:04:11 +00:00
continue ;
}
2005-06-22 17:10:13 +00:00
v1 = i % cl_lightstyle [ j ] . length ;
v1 = cl_lightstyle [ j ] . map [ v1 ] - ' a ' ;
v2 = ( i + 1 ) % cl_lightstyle [ j ] . length ;
v2 = cl_lightstyle [ j ] . map [ v2 ] - ' a ' ;
2011-04-20 23:05:45 +00:00
vd = v1 - v2 ;
if ( ! r_lightstylesmooth . ival | | vd < - r_lightstylesmooth_limit . ival | | vd > r_lightstylesmooth_limit . ival )
2015-04-14 23:12:17 +00:00
d_lightstylevalue [ j ] = v1 * 22 * r_lightstylescale . value ;
2011-04-20 23:05:45 +00:00
else
2015-04-14 23:12:17 +00:00
d_lightstylevalue [ j ] = ( v1 * ( 1 - f ) + v2 * ( f ) ) * 22 * r_lightstylescale . value ;
2010-05-01 22:47:47 +00:00
}
2020-04-29 10:43:22 +00:00
if ( r_fullbright . modified ! = fbmodcount )
{
fbmodcount = r_fullbright . modified ;
for ( j = 0 ; j < cl_max_lightstyles ; j + + )
{
if ( r_fullbright . value )
cl_lightstyle [ j ] . colourkey = 0xff ;
else
cl_lightstyle [ j ] . colourkey = ( int ) ( cl_lightstyle [ j ] . colours [ 0 ] * 0x400 ) ^ ( int ) ( cl_lightstyle [ j ] . colours [ 1 ] * 0x100000 ) ^ ( int ) ( cl_lightstyle [ j ] . colours [ 2 ] * 0x40000000 ) ;
}
}
2004-08-22 22:29:09 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
DYNAMIC LIGHTS BLEND RENDERING
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
void AddLightBlend ( float r , float g , float b , float a2 )
{
float a ;
2016-01-18 05:22:07 +00:00
float * sw_blend = r_refdef . playerview - > screentint ;
2004-08-22 22:29:09 +00:00
2005-08-28 05:21:25 +00:00
r = bound ( 0 , r , 1 ) ;
g = bound ( 0 , g , 1 ) ;
b = bound ( 0 , b , 1 ) ;
2010-03-25 22:56:11 +00:00
sw_blend [ 3 ] = a = sw_blend [ 3 ] + a2 * ( 1 - sw_blend [ 3 ] ) ;
2004-08-22 22:29:09 +00:00
a2 = a2 / a ;
2010-03-25 22:56:11 +00:00
sw_blend [ 0 ] = sw_blend [ 0 ] * ( 1 - a2 ) + r * a2 ;
sw_blend [ 1 ] = sw_blend [ 1 ] * ( 1 - a2 ) + g * a2 ;
sw_blend [ 2 ] = sw_blend [ 2 ] * ( 1 - a2 ) + b * a2 ;
2004-08-22 22:29:09 +00:00
//Con_Printf("AddLightBlend(): %4.2f %4.2f %4.2f %4.6f\n", v_blend[0], v_blend[1], v_blend[2], v_blend[3]);
}
2011-12-23 03:12:29 +00:00
# define FLASHBLEND_VERTS 16
static float bubble_sintable [ FLASHBLEND_VERTS + 1 ] , bubble_costable [ FLASHBLEND_VERTS + 1 ] ;
2004-08-22 22:29:09 +00:00
2011-10-27 16:16:29 +00:00
static void R_InitBubble ( void )
2009-06-21 17:45:33 +00:00
{
2004-08-22 22:29:09 +00:00
float a ;
int i ;
float * bub_sin , * bub_cos ;
bub_sin = bubble_sintable ;
bub_cos = bubble_costable ;
2011-12-23 03:12:29 +00:00
for ( i = FLASHBLEND_VERTS ; i > = 0 ; i - - )
2004-08-22 22:29:09 +00:00
{
2011-12-23 03:12:29 +00:00
a = i / ( float ) FLASHBLEND_VERTS * M_PI * 2 ;
2004-08-22 22:29:09 +00:00
* bub_sin + + = sin ( a ) ;
* bub_cos + + = cos ( a ) ;
}
}
2010-03-26 02:17:55 +00:00
avec4_t flashblend_colours [ FLASHBLEND_VERTS + 1 ] ;
vecV_t flashblend_vcoords [ FLASHBLEND_VERTS + 1 ] ;
vec2_t flashblend_tccoords [ FLASHBLEND_VERTS + 1 ] ;
2010-07-11 10:53:13 +00:00
index_t flashblend_indexes [ FLASHBLEND_VERTS * 3 ] ;
2011-09-03 03:49:43 +00:00
index_t flashblend_fsindexes [ 6 ] = { 0 , 1 , 2 , 0 , 2 , 3 } ;
2010-03-26 02:17:55 +00:00
mesh_t flashblend_mesh ;
2011-09-03 03:49:43 +00:00
mesh_t flashblend_fsmesh ;
2015-10-11 11:34:58 +00:00
shader_t * occluded_shader ;
2010-03-26 02:17:55 +00:00
shader_t * flashblend_shader ;
2017-10-31 22:52:58 +00:00
shader_t * deferredlight_shader [ LSHADER_MODES ] ;
2011-12-23 03:12:29 +00:00
void R_GenerateFlashblendTexture ( void )
{
float dx , dy ;
int x , y , a ;
unsigned char pixels [ 32 ] [ 32 ] [ 4 ] ;
for ( y = 0 ; y < 32 ; y + + )
{
dy = ( y - 15.5f ) * ( 1.0f / 16.0f ) ;
for ( x = 0 ; x < 32 ; x + + )
{
dx = ( x - 15.5f ) * ( 1.0f / 16.0f ) ;
a = ( int ) ( ( ( 1.0f / ( dx * dx + dy * dy + 0.2f ) ) - ( 1.0f / ( 1.0f + 0.2 ) ) ) * 32.0f / ( 1.0f / ( 1.0f + 0.2 ) ) ) ;
a = bound ( 0 , a , 255 ) ;
pixels [ y ] [ x ] [ 0 ] = a ;
pixels [ y ] [ x ] [ 1 ] = a ;
pixels [ y ] [ x ] [ 2 ] = a ;
pixels [ y ] [ x ] [ 3 ] = 255 ;
}
}
2019-01-20 01:00:18 +00:00
R_LoadReplacementTexture ( " ***flashblend*** " , NULL , IF_LINEAR , pixels , 32 , 32 , TF_RGBA32 ) ;
2011-12-23 03:12:29 +00:00
}
2010-03-26 02:17:55 +00:00
void R_InitFlashblends ( void )
{
int i ;
2011-12-23 03:12:29 +00:00
R_InitBubble ( ) ;
2010-03-26 02:17:55 +00:00
for ( i = 0 ; i < FLASHBLEND_VERTS ; i + + )
{
flashblend_indexes [ i * 3 + 0 ] = 0 ;
if ( i + 1 = = FLASHBLEND_VERTS )
flashblend_indexes [ i * 3 + 1 ] = 1 ;
else
flashblend_indexes [ i * 3 + 1 ] = i + 2 ;
flashblend_indexes [ i * 3 + 2 ] = i + 1 ;
2011-12-23 03:12:29 +00:00
flashblend_tccoords [ i + 1 ] [ 0 ] = 0.5 + bubble_sintable [ i ] * 0.5 ;
flashblend_tccoords [ i + 1 ] [ 1 ] = 0.5 + bubble_costable [ i ] * 0.5 ;
2010-03-26 02:17:55 +00:00
}
2011-12-23 03:12:29 +00:00
flashblend_tccoords [ 0 ] [ 0 ] = 0.5 ;
flashblend_tccoords [ 0 ] [ 1 ] = 0.5 ;
2010-03-26 02:17:55 +00:00
flashblend_mesh . numvertexes = FLASHBLEND_VERTS + 1 ;
flashblend_mesh . xyz_array = flashblend_vcoords ;
flashblend_mesh . st_array = flashblend_tccoords ;
2013-08-27 13:18:09 +00:00
flashblend_mesh . colors4f_array [ 0 ] = flashblend_colours ;
2010-03-26 02:17:55 +00:00
flashblend_mesh . indexes = flashblend_indexes ;
flashblend_mesh . numindexes = FLASHBLEND_VERTS * 3 ;
flashblend_mesh . istrifan = true ;
2011-09-03 03:49:43 +00:00
flashblend_fsmesh . numvertexes = 4 ;
flashblend_fsmesh . xyz_array = flashblend_vcoords ;
flashblend_fsmesh . st_array = flashblend_tccoords ;
2013-08-27 13:18:09 +00:00
flashblend_fsmesh . colors4f_array [ 0 ] = flashblend_colours ;
2011-09-03 03:49:43 +00:00
flashblend_fsmesh . indexes = flashblend_fsindexes ;
flashblend_fsmesh . numindexes = 6 ;
flashblend_fsmesh . istrifan = true ;
2011-12-23 03:12:29 +00:00
R_GenerateFlashblendTexture ( ) ;
2013-08-21 07:14:39 +00:00
flashblend_shader = R_RegisterShader ( " flashblend " , SUF_NONE ,
2010-03-26 02:17:55 +00:00
" { \n "
2011-12-23 03:12:29 +00:00
" program defaultadditivesprite \n "
2010-03-26 02:17:55 +00:00
" { \n "
2011-12-23 03:12:29 +00:00
" map ***flashblend*** \n "
2010-03-26 02:17:55 +00:00
" blendfunc gl_one gl_one \n "
" rgbgen vertex \n "
" alphagen vertex \n "
2013-10-29 17:38:22 +00:00
" nodepth \n "
2010-03-26 02:17:55 +00:00
" } \n "
" } \n "
) ;
2015-10-11 11:34:58 +00:00
occluded_shader = R_RegisterShader ( " flashblend_occlusiontest " , SUF_NONE ,
" { \n "
" program defaultadditivesprite \n "
" { \n "
" maskcolor \n "
" maskalpha \n "
" } \n "
" } \n "
) ;
2017-10-31 22:52:58 +00:00
memset ( deferredlight_shader , 0 , sizeof ( deferredlight_shader ) ) ;
2010-03-26 02:17:55 +00:00
}
2013-10-29 17:38:22 +00:00
static qboolean R_BuildDlightMesh ( dlight_t * light , float colscale , float radscale , int dtype )
2004-08-22 22:29:09 +00:00
{
int i , j ;
// float a;
vec3_t v ;
float rad ;
float * bub_sin , * bub_cos ;
2009-11-04 21:16:50 +00:00
vec3_t colour ;
2004-08-22 22:29:09 +00:00
bub_sin = bubble_sintable ;
bub_cos = bubble_costable ;
2011-09-03 03:49:43 +00:00
rad = light - > radius * radscale ;
2004-08-22 22:29:09 +00:00
2009-11-04 21:16:50 +00:00
VectorCopy ( light - > color , colour ) ;
if ( light - > fov )
{
float a = - DotProduct ( light - > axis [ 0 ] , vpn ) ;
colour [ 0 ] * = a ;
colour [ 1 ] * = a ;
colour [ 2 ] * = a ;
rad * = a ;
rad * = 0.33 ;
}
2019-09-10 15:40:04 +00:00
if ( light - > style > = 0 & & light - > style < countof ( d_lightstylevalue ) )
2011-12-27 08:35:19 +00:00
{
2019-09-10 15:40:04 +00:00
colscale * = d_lightstylevalue [ light - > style ] / 255.0f ;
2011-12-27 08:35:19 +00:00
}
2009-11-04 21:16:50 +00:00
2004-08-22 22:29:09 +00:00
VectorSubtract ( light - > origin , r_origin , v ) ;
2016-10-22 07:06:51 +00:00
if ( dtype ! = 1 & & Length ( v ) < rad + r_refdef . mindist * 2 )
2004-08-22 22:29:09 +00:00
{ // view is inside the dlight
2011-09-03 03:49:43 +00:00
return false ;
2004-08-22 22:29:09 +00:00
}
2011-12-27 08:35:19 +00:00
flashblend_colours [ 0 ] [ 0 ] = colour [ 0 ] * colscale ;
flashblend_colours [ 0 ] [ 1 ] = colour [ 1 ] * colscale ;
flashblend_colours [ 0 ] [ 2 ] = colour [ 2 ] * colscale ;
2010-03-26 02:17:55 +00:00
flashblend_colours [ 0 ] [ 3 ] = 1 ;
2011-09-03 03:49:43 +00:00
VectorCopy ( light - > origin , flashblend_vcoords [ 0 ] ) ;
2011-10-27 16:16:29 +00:00
for ( i = FLASHBLEND_VERTS ; i > 0 ; i - - )
2004-08-22 22:29:09 +00:00
{
for ( j = 0 ; j < 3 ; j + + )
2010-03-26 02:17:55 +00:00
flashblend_vcoords [ i ] [ j ] = light - > origin [ j ] + ( vright [ j ] * ( * bub_cos ) +
2004-08-22 22:29:09 +00:00
+ vup [ j ] * ( * bub_sin ) ) * rad ;
bub_sin + + ;
bub_cos + + ;
}
2013-10-29 17:38:22 +00:00
if ( dtype = = 0 )
{
//flashblend 3d-ish
2011-09-03 03:49:43 +00:00
VectorMA ( flashblend_vcoords [ 0 ] , - rad / 1.5 , vpn , flashblend_vcoords [ 0 ] ) ;
2013-10-29 17:38:22 +00:00
}
else if ( dtype ! = 1 )
2011-09-03 03:49:43 +00:00
{
2013-10-29 17:38:22 +00:00
//prepass lights needs to be fully infront of the light. the glsl is a fullscreen-style effect, but we can benefit from early-z and scissoring
2011-09-03 03:49:43 +00:00
vec3_t diff ;
VectorSubtract ( r_origin , light - > origin , diff ) ;
VectorNormalize ( diff ) ;
2011-10-27 16:16:29 +00:00
for ( i = 0 ; i < = FLASHBLEND_VERTS ; i + + )
2011-09-03 03:49:43 +00:00
VectorMA ( flashblend_vcoords [ i ] , rad , diff , flashblend_vcoords [ i ] ) ;
}
return true ;
2004-08-22 22:29:09 +00:00
}
/*
= = = = = = = = = = = = =
R_RenderDlights
= = = = = = = = = = = = =
*/
2011-10-27 16:16:29 +00:00
void R_RenderDlights ( void )
2004-08-22 22:29:09 +00:00
{
int i ;
dlight_t * l ;
2005-07-09 15:47:20 +00:00
vec3_t waste1 , waste2 ;
2011-04-20 23:34:13 +00:00
unsigned int beflags = 0 ;
2013-10-29 17:38:22 +00:00
float intensity , cscale ;
qboolean coronastyle ;
2014-04-13 04:23:13 +00:00
qboolean flashstyle ;
2014-04-24 01:53:01 +00:00
float dist ;
2004-08-22 22:29:09 +00:00
2013-10-29 17:38:22 +00:00
if ( ! r_coronas . value & & ! r_flashblend . value )
return ;
2004-08-22 22:29:09 +00:00
2009-11-04 21:16:50 +00:00
l = cl_dlights + rtlights_first ;
for ( i = rtlights_first ; i < rtlights_max ; i + + , l + + )
2004-08-22 22:29:09 +00:00
{
2011-12-27 08:35:19 +00:00
if ( ! l - > radius )
continue ;
if ( l - > corona < = 0 )
2004-08-22 22:29:09 +00:00
continue ;
2005-07-09 15:47:20 +00:00
2014-04-13 04:23:13 +00:00
//dlights emitting from the local player are not visible as flashblends
if ( l - > key = = r_refdef . playerview - > viewentity )
continue ; //was a glow
if ( l - > key = = - ( r_refdef . playerview - > viewentity ) )
continue ; //was a muzzleflash
2014-08-15 02:20:41 +00:00
coronastyle = ( l - > flags & ( LFLAG_NORMALMODE | LFLAG_REALTIMEMODE ) ) & & r_coronas . value ;
flashstyle = ( ( l - > flags & LFLAG_FLASHBLEND ) & & r_flashblend . value ) ;
2014-04-13 04:23:13 +00:00
if ( ! coronastyle & & ! flashstyle )
continue ;
if ( coronastyle & & flashstyle )
flashstyle = false ;
2008-01-24 01:24:10 +00:00
2013-10-29 17:38:22 +00:00
cscale = l - > coronascale ;
2014-04-13 04:23:13 +00:00
intensity = l - > corona ; // * 0.25;
2013-10-29 17:38:22 +00:00
if ( coronastyle )
2019-02-16 19:09:07 +00:00
intensity * = r_coronas . value * r_coronas_intensity . value ;
2012-01-01 02:26:42 +00:00
else
2013-10-29 17:38:22 +00:00
intensity * = r_flashblend . value ;
if ( intensity < = 0 | | cscale < = 0 )
2012-01-01 02:26:42 +00:00
continue ;
2014-04-24 01:53:01 +00:00
//prevent the corona from intersecting with the near clip plane by just fading it away if its too close
VectorSubtract ( l - > origin , r_refdef . vieworg , waste1 ) ;
dist = VectorLength ( waste1 ) ;
2016-07-12 00:40:13 +00:00
if ( dist < r_coronas_mindist . value + r_coronas_fadedist . value )
2014-04-24 01:53:01 +00:00
{
2016-07-12 00:40:13 +00:00
if ( dist < = r_coronas_mindist . value )
2014-04-24 01:53:01 +00:00
continue ;
2016-07-12 00:40:13 +00:00
intensity * = ( dist - r_coronas_mindist . value ) / r_coronas_fadedist . value ;
2014-04-24 01:53:01 +00:00
}
2012-01-01 02:26:42 +00:00
/*coronas use depth testing to compute visibility*/
2013-10-29 17:38:22 +00:00
if ( coronastyle )
2005-07-09 15:47:20 +00:00
{
2015-10-11 11:34:58 +00:00
int method ;
2021-04-14 05:21:04 +00:00
if ( r_refdef . recurse )
method = 1 ; //don't confuse queries... FIXME: splitscreen/PIP will still have issues.
else if ( ! * r_coronas_occlusion . string )
2016-07-12 00:40:13 +00:00
method = 4 ; //default to using hardware queries where possible.
2015-10-11 11:34:58 +00:00
else
method = r_coronas_occlusion . ival ;
switch ( method )
2015-09-10 10:16:26 +00:00
{
2015-10-11 11:34:58 +00:00
case 2 :
2015-09-10 10:16:26 +00:00
if ( TraceLineR ( r_refdef . vieworg , l - > origin , waste1 , waste2 ) )
continue ;
2015-10-11 11:34:58 +00:00
break ;
case 0 :
break ;
case 3 :
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
if ( qrenderer = = QR_OPENGL )
2015-10-11 11:34:58 +00:00
{
float depth ;
vec3_t out ;
float v [ 4 ] , tempv [ 4 ] ;
float mvp [ 16 ] ;
v [ 0 ] = l - > origin [ 0 ] ;
v [ 1 ] = l - > origin [ 1 ] ;
v [ 2 ] = l - > origin [ 2 ] ;
v [ 3 ] = 1 ;
2017-12-15 06:56:40 +00:00
Matrix4_Multiply ( r_refdef . m_projection_std , r_refdef . m_view , mvp ) ;
2015-10-11 11:34:58 +00:00
Matrix4x4_CM_Transform4 ( mvp , v , tempv ) ;
tempv [ 0 ] / = tempv [ 3 ] ;
tempv [ 1 ] / = tempv [ 3 ] ;
tempv [ 2 ] / = tempv [ 3 ] ;
out [ 0 ] = ( 1 + tempv [ 0 ] ) / 2 ;
out [ 1 ] = ( 1 + tempv [ 1 ] ) / 2 ;
out [ 2 ] = ( 1 + tempv [ 2 ] ) / 2 ;
out [ 0 ] = out [ 0 ] * r_refdef . pxrect . width + r_refdef . pxrect . x ;
out [ 1 ] = out [ 1 ] * r_refdef . pxrect . height + r_refdef . pxrect . y ;
if ( tempv [ 3 ] < 0 )
out [ 2 ] * = - 1 ;
if ( out [ 2 ] < 0 )
continue ;
//FIXME: in terms of performance, mixing reads+draws is BAD BAD BAD. SERIOUSLY BAD
2016-07-12 00:40:13 +00:00
//it would be an improvement to calculate all of these at once.
2015-10-11 11:34:58 +00:00
qglReadPixels ( out [ 0 ] , out [ 1 ] , 1 , 1 , GL_DEPTH_COMPONENT , GL_FLOAT , & depth ) ;
if ( depth < out [ 2 ] )
continue ;
2016-07-12 00:40:13 +00:00
break ;
2015-10-11 11:34:58 +00:00
}
2016-07-12 00:40:13 +00:00
# endif
//other renderers fall through
2015-10-11 11:34:58 +00:00
case 4 :
2016-07-12 00:40:13 +00:00
# ifdef GLQUAKE
if ( qrenderer = = QR_OPENGL & & qglGenQueriesARB )
2015-10-11 11:34:58 +00:00
{
GLuint res ;
qboolean requery = true ;
2016-07-16 14:24:06 +00:00
if ( r_refdef . recurse )
requery = false ;
else if ( l - > coronaocclusionquery )
2015-10-11 11:34:58 +00:00
{
qglGetQueryObjectuivARB ( l - > coronaocclusionquery , GL_QUERY_RESULT_AVAILABLE_ARB , & res ) ;
if ( res )
qglGetQueryObjectuivARB ( l - > coronaocclusionquery , GL_QUERY_RESULT_ARB , & l - > coronaocclusionresult ) ;
else if ( ! l - > coronaocclusionresult )
continue ; //query still running, nor currently visible.
else
requery = false ;
}
else
{
qglGenQueriesARB ( 1 , & l - > coronaocclusionquery ) ;
}
if ( requery )
{
qglBeginQueryARB ( GL_SAMPLES_PASSED_ARB , l - > coronaocclusionquery ) ;
2016-07-12 00:40:13 +00:00
R_BuildDlightMesh ( l , intensity * 10 , cscale * .1 , coronastyle ) ;
2015-10-11 11:34:58 +00:00
BE_DrawMesh_Single ( occluded_shader , & flashblend_mesh , NULL , beflags ) ;
qglEndQueryARB ( GL_SAMPLES_PASSED_ARB ) ;
}
if ( ! l - > coronaocclusionresult )
continue ;
2016-07-12 00:40:13 +00:00
break ;
2015-10-11 11:34:58 +00:00
}
# endif
2016-07-12 00:40:13 +00:00
//other renderers fall through
default :
case 1 :
if ( CL_TraceLine ( r_refdef . vieworg , l - > origin , waste1 , NULL , NULL ) < 1 )
continue ;
break ;
2015-09-10 10:16:26 +00:00
}
2005-07-09 15:47:20 +00:00
}
2012-01-01 02:26:42 +00:00
2013-10-29 17:38:22 +00:00
if ( ! R_BuildDlightMesh ( l , intensity , cscale , coronastyle ) & & ! coronastyle )
2012-01-01 02:26:42 +00:00
AddLightBlend ( l - > color [ 0 ] , l - > color [ 1 ] , l - > color [ 2 ] , l - > radius * 0.0003 ) ;
2011-09-03 03:49:43 +00:00
else
2015-05-03 19:57:46 +00:00
BE_DrawMesh_Single ( flashblend_shader , & flashblend_mesh , NULL , ( coronastyle ? BEF_FORCENODEPTH | BEF_FORCEADDITIVE : 0 ) | beflags ) ;
2011-09-03 03:49:43 +00:00
}
}
2018-01-22 19:18:04 +00:00
qboolean Sh_GenerateShadowMap ( dlight_t * l , int lightflags ) ;
2017-10-31 22:52:58 +00:00
qboolean Sh_CullLight ( dlight_t * dl , qbyte * vvis ) ;
2011-09-03 03:49:43 +00:00
void R_GenDlightMesh ( struct batch_s * batch )
{
static mesh_t * meshptr ;
2020-08-13 08:39:48 +00:00
dlight_t * l = cl_dlights + batch - > user . dlight . lightidx ;
2017-10-31 22:52:58 +00:00
vec3_t colour ;
2011-09-03 03:49:43 +00:00
2020-08-13 08:39:48 +00:00
int lightflags = batch - > user . dlight . lightmode ;
2016-11-20 20:52:41 +00:00
2017-10-31 22:52:58 +00:00
VectorCopy ( l - > color , colour ) ;
2019-09-10 15:40:04 +00:00
if ( l - > style > = 0 & & l - > style < cl_max_lightstyles )
2017-10-31 22:52:58 +00:00
{
2019-09-10 15:40:04 +00:00
colour [ 0 ] * = cl_lightstyle [ l - > style ] . colours [ 0 ] * d_lightstylevalue [ l - > style ] / 255.0f ;
colour [ 1 ] * = cl_lightstyle [ l - > style ] . colours [ 1 ] * d_lightstylevalue [ l - > style ] / 255.0f ;
colour [ 2 ] * = cl_lightstyle [ l - > style ] . colours [ 2 ] * d_lightstylevalue [ l - > style ] / 255.0f ;
2017-10-31 22:52:58 +00:00
}
else
{
colour [ 0 ] * = r_lightstylescale . value ;
colour [ 1 ] * = r_lightstylescale . value ;
colour [ 2 ] * = r_lightstylescale . value ;
}
if ( colour [ 0 ] < 0.001 & & colour [ 1 ] < 0.001 & & colour [ 2 ] < 0.001 )
{ //just switch these off.
batch - > meshes = 0 ;
return ;
}
BE_SelectDLight ( l , colour , l - > axis , lightflags ) ;
2016-11-20 21:05:10 +00:00
# ifdef RTLIGHTS
2016-11-20 20:52:41 +00:00
if ( lightflags & LSHADER_SMAP )
{
2018-01-22 19:18:04 +00:00
if ( ! Sh_GenerateShadowMap ( l , lightflags ) )
2016-11-20 20:52:41 +00:00
{
batch - > meshes = 0 ;
return ;
}
BE_SelectEntity ( & r_worldentity ) ;
BE_SelectMode ( BEM_STANDARD ) ;
}
2017-10-31 22:52:58 +00:00
else if ( Sh_CullLight ( l , r_refdef . scenevis ) )
{
batch - > meshes = 0 ;
return ;
}
2016-11-20 21:05:10 +00:00
# endif
2011-09-03 03:49:43 +00:00
2013-10-29 17:38:22 +00:00
if ( ! R_BuildDlightMesh ( l , 2 , 1 , 2 ) )
2011-09-03 03:49:43 +00:00
{
int i ;
static vec2_t s [ 4 ] = { { 1 , - 1 } , { - 1 , - 1 } , { - 1 , 1 } , { 1 , 1 } } ;
for ( i = 0 ; i < 4 ; i + + )
{
VectorMA ( r_origin , 32 , vpn , flashblend_vcoords [ i ] ) ;
VectorMA ( flashblend_vcoords [ i ] , s [ i ] [ 0 ] * 320 , vright , flashblend_vcoords [ i ] ) ;
VectorMA ( flashblend_vcoords [ i ] , s [ i ] [ 1 ] * 320 , vup , flashblend_vcoords [ i ] ) ;
}
meshptr = & flashblend_fsmesh ;
}
else
{
meshptr = & flashblend_mesh ;
}
batch - > mesh = & meshptr ;
2017-10-31 22:52:58 +00:00
RQuantAdd ( RQUANT_RTLIGHT_DRAWN , 1 ) ;
2011-09-03 03:49:43 +00:00
}
void R_GenDlightBatches ( batch_t * batches [ ] )
{
2018-01-03 18:49:11 +00:00
# ifdef RTLIGHTS
2014-09-22 17:49:45 +00:00
int i , j , sort ;
2011-09-03 03:49:43 +00:00
dlight_t * l ;
batch_t * b ;
2016-11-20 20:52:41 +00:00
int lmode ;
2017-12-15 06:56:40 +00:00
unsigned modes ;
extern cvar_t r_shadow_realtime_dlight ;
extern cvar_t r_shadow_realtime_world ;
2016-11-20 20:52:41 +00:00
if ( ! r_lightprepass )
2014-10-11 19:39:45 +00:00
return ;
2017-12-28 16:24:50 +00:00
modes = 0 ;
2017-12-15 06:56:40 +00:00
if ( r_shadow_realtime_dlight . ival )
modes | = LFLAG_NORMALMODE ;
if ( r_shadow_realtime_world . ival )
modes | = LFLAG_REALTIMEMODE ;
if ( ! modes )
return ;
2017-10-31 22:52:58 +00:00
if ( ! deferredlight_shader [ 0 ] )
2016-11-20 20:52:41 +00:00
{
2017-10-31 22:52:58 +00:00
const char * deferredlight_shader_code =
2011-09-03 03:49:43 +00:00
" { \n "
2017-10-31 22:52:58 +00:00
" deferredlight \n "
2011-09-03 03:49:43 +00:00
" surfaceparm nodlight \n "
2016-11-20 20:52:41 +00:00
" { \n "
2017-10-31 22:52:58 +00:00
" program lpp_light \n "
2016-11-20 20:52:41 +00:00
" blendfunc gl_one gl_one \n "
" nodepthtest \n "
2017-10-31 22:52:58 +00:00
" map $gbuffer0 \n " //depth
" map $gbuffer1 \n " //normals.rgb specexp.a
2016-11-20 20:52:41 +00:00
" } \n "
" } \n "
2017-10-31 22:52:58 +00:00
;
deferredlight_shader [ 0 ] = R_RegisterShader ( " deferredlight " , SUF_NONE , deferredlight_shader_code ) ;
# ifdef RTLIGHTS
deferredlight_shader [ LSHADER_SMAP ] = R_RegisterShader ( " deferredlight#PCF " , SUF_NONE , deferredlight_shader_code ) ;
2016-11-20 21:05:10 +00:00
# endif
2016-11-20 20:52:41 +00:00
}
2011-09-03 03:49:43 +00:00
l = cl_dlights + rtlights_first ;
for ( i = rtlights_first ; i < rtlights_max ; i + + , l + + )
{
if ( ! l - > radius )
continue ;
2017-12-15 06:56:40 +00:00
if ( ! ( modes & l - > flags ) )
continue ;
2011-09-03 03:49:43 +00:00
if ( R_CullSphere ( l - > origin , l - > radius ) )
2017-10-31 22:52:58 +00:00
{
RQuantAdd ( RQUANT_RTLIGHT_CULL_FRUSTUM , 1 ) ;
2011-09-03 03:49:43 +00:00
continue ;
2017-10-31 22:52:58 +00:00
}
2011-09-03 03:49:43 +00:00
2016-11-20 20:52:41 +00:00
lmode = 0 ;
2016-11-20 21:05:10 +00:00
# ifdef RTLIGHTS
2016-11-20 20:52:41 +00:00
if ( ! ( ( ( i > = RTL_FIRST ) ? ! r_shadow_realtime_world_shadows . ival : ! r_shadow_realtime_dlight_shadows . ival ) | | l - > flags & LFLAG_NOSHADOWS ) )
lmode | = LSHADER_SMAP ;
2016-11-20 21:05:10 +00:00
# endif
2016-11-20 20:52:41 +00:00
// if (TEXLOADED(l->cubetexture))
// lmode |= LSHADER_CUBE;
2011-09-03 03:49:43 +00:00
b = BE_GetTempBatch ( ) ;
if ( ! b )
return ;
b - > flags = 0 ;
2017-10-31 22:52:58 +00:00
b - > shader = deferredlight_shader [ lmode ] ;
2016-11-20 20:52:41 +00:00
sort = b - > shader - > sort ;
2011-09-03 03:49:43 +00:00
b - > buildmeshes = R_GenDlightMesh ;
b - > ent = & r_worldentity ;
b - > mesh = NULL ;
b - > firstmesh = 0 ;
b - > meshes = 1 ;
2015-05-03 19:57:46 +00:00
b - > skin = NULL ;
2011-09-03 03:49:43 +00:00
b - > texture = NULL ;
2014-09-22 17:49:45 +00:00
for ( j = 0 ; j < MAXRLIGHTMAPS ; j + + )
b - > lightmap [ j ] = - 1 ;
2020-08-13 08:39:48 +00:00
b - > user . dlight . lightidx = i ;
b - > user . dlight . lightmode = lmode ;
2017-12-15 06:56:40 +00:00
b - > flags | = BEF_NOSHADOWS | BEF_NODLIGHT ; //that would be weeird
2011-12-23 03:12:29 +00:00
b - > vbo = NULL ;
2011-09-03 03:49:43 +00:00
b - > next = batches [ sort ] ;
batches [ sort ] = b ;
2004-08-22 22:29:09 +00:00
}
2018-01-03 18:49:11 +00:00
# endif
2004-08-22 22:29:09 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
DYNAMIC LIGHTS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/*
= = = = = = = = = = = = =
R_PushDlights
= = = = = = = = = = = = =
*/
2010-11-10 03:32:47 +00:00
void R_PushDlights ( void )
2004-08-22 22:29:09 +00:00
{
int i ;
dlight_t * l ;
2021-12-20 10:06:09 +00:00
r_dlightframecount + + ; // because the count hasn't
2004-08-22 22:29:09 +00:00
// advanced yet for this frame
2011-10-27 16:16:29 +00:00
# ifdef RTLIGHTS
/*if we're doing full rtlighting only, then don't bother calculating old-style dlights as they won't be visible anyway*/
2012-07-05 19:42:36 +00:00
if ( r_shadow_realtime_world . ival & & r_shadow_realtime_world_lightmaps . value < 0.1 )
2011-10-27 16:16:29 +00:00
return ;
# endif
2021-06-21 13:46:06 +00:00
if ( r_dynamic . ival < = 0 | | ! r_worldentity . model )
2004-08-22 22:29:09 +00:00
return ;
2021-06-21 13:46:06 +00:00
if ( r_worldentity . model - > loadstate ! = MLS_LOADED )
2006-02-28 00:46:04 +00:00
return ;
2004-08-22 22:29:09 +00:00
2021-06-21 13:46:06 +00:00
if ( ! r_worldentity . model - > nodes )
return ;
currentmodel = r_worldentity . model ;
2011-12-05 15:23:40 +00:00
if ( ! currentmodel - > funcs . MarkLights )
return ;
2004-08-22 22:29:09 +00:00
2009-11-04 21:16:50 +00:00
l = cl_dlights + rtlights_first ;
for ( i = rtlights_first ; i < = DL_LAST ; i + + , l + + )
2004-08-22 22:29:09 +00:00
{
2011-07-30 14:14:56 +00:00
if ( ! l - > radius | | ! ( l - > flags & LFLAG_LIGHTMAP ) )
2004-08-22 22:29:09 +00:00
continue ;
2020-06-01 01:30:31 +00:00
currentmodel - > funcs . MarkLights ( l , ( dlightbitmask_t ) 1u < < i , currentmodel - > nodes ) ;
2004-08-22 22:29:09 +00:00
}
}
2012-01-01 02:26:42 +00:00
/////////////////////////////////////////////////////////////
//rtlight loading
# ifdef RTLIGHTS
2018-11-19 06:37:25 +00:00
//These affect importing
static cvar_t r_editlights_import_radius = CVARAD ( " r_editlights_import_radius " , " 1 " , " r_editlights_quakelightsizescale " , " changes size of light entities loaded from a map " ) ;
static cvar_t r_editlights_import_ambient = CVARD ( " r_editlights_import_ambient " , " 0 " , " ambient light scaler for imported lights " ) ;
static cvar_t r_editlights_import_diffuse = CVARD ( " r_editlights_import_diffuse " , " 1 " , " diffuse light scaler for imported lights " ) ;
static cvar_t r_editlights_import_specular = CVARD ( " r_editlights_import_specular " , " 1 " , " specular light scaler for imported lights " ) ; //excessive, but noticable. its called stylized, okay? shiesh, some people
//these are just for the crappy editor
static cvar_t r_editlights = CVARD ( " r_editlights " , " 0 " , " enables .rtlights file editing mode. Consider using csaddon/equivelent instead. " ) ;
static cvar_t r_editlights_cursordistance = CVARD ( " r_editlights_cursordistance " , " 1024 " , " maximum distance of cursor from eye " ) ;
static cvar_t r_editlights_cursorpushoff = CVARD ( " r_editlights_cursorpushoff " , " 4 " , " how far to push the cursor off the impacted surface " ) ;
static cvar_t r_editlights_cursorpushback = CVARD ( " r_editlights_cursorpushback " , " 0 " , " how far to pull the cursor back toward the eye, for some reason " ) ;
static cvar_t r_editlights_cursorgrid = CVARD ( " r_editlights_cursorgrid " , " 1 " , " snaps cursor to this grid size " ) ;
//internal settings
static qboolean r_editlights_locked = false ; //don't change the selected light
static int r_editlights_selected = - 1 ; //the light closest to the cursor
static vec3_t r_editlights_cursor ; //the position of the crosshair/cursor (new lights will be spawned here)
static dlight_t r_editlights_copybuffer ; //written by r_editlights_copyinfo, read by r_editlights_pasteinfo. FIXME: use system clipboard?
2021-08-28 07:09:54 +00:00
qboolean R_ImportRTLights ( const char * entlump , int importmode )
2012-01-01 02:26:42 +00:00
{
2018-07-22 11:49:37 +00:00
typedef enum lighttype_e { LIGHTTYPE_MINUSX , LIGHTTYPE_RECIPX , LIGHTTYPE_RECIPXX , LIGHTTYPE_INFINITE , LIGHTTYPE_LOCALMIN , LIGHTTYPE_RECIPXX2 , LIGHTTYPE_SUN } lighttype_t ;
2012-01-01 02:26:42 +00:00
/*I'm using the DP code so I know I'll get the DP results*/
2013-05-11 05:03:07 +00:00
int entnum , style , islight , skin , pflags , n ;
2012-01-01 02:26:42 +00:00
lighttype_t type ;
2018-07-22 11:49:37 +00:00
float origin [ 3 ] , angles [ 3 ] , mangle [ 3 ] , radius , color [ 3 ] , light [ 4 ] , fadescale , lightscale , originhack [ 3 ] , overridecolor [ 3 ] , colourscales [ 3 ] , vec [ 4 ] ;
2012-01-01 02:26:42 +00:00
char key [ 256 ] , value [ 8192 ] ;
2018-07-22 11:49:37 +00:00
char targetname [ 256 ] , target [ 256 ] ;
2012-01-01 02:26:42 +00:00
int nest ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
qboolean okay = false ;
2018-07-22 11:49:37 +00:00
infobuf_t targets ;
const char * lmp ;
2021-08-23 06:37:30 +00:00
qboolean rerelease = false ;
float fade [ 2 ] ;
2018-07-22 11:49:37 +00:00
memset ( & targets , 0 , sizeof ( targets ) ) ;
2012-01-01 02:26:42 +00:00
2017-04-18 11:12:17 +00:00
//a quick note about tenebrae:
//by default, tenebrae's rtlights come from the server via static entities, which is all fancy and posh and actually fairly nice... if all servers actually did it.
//(the tenebrae gamecode uses spawnflag 2048 for static lights. note the pflags_fulldynamic fte/dp vs tenebrae difference)
//failing that, it will insert lights with some crappy fixed radius around only all 'classname light' entities, without any colours or anything, vanilla only.
//such lights are ONLY created if they're not near some other existing light (like a static entity one).
//this can result in FTE having noticably more and bigger lights than tenebrae. shadowmapping doesn't help performance either.
2018-07-22 11:49:37 +00:00
//handle doom3's header
2012-01-01 02:26:42 +00:00
COM_Parse ( entlump ) ;
if ( ! strcmp ( com_token , " Version " ) )
{
entlump = COM_Parse ( entlump ) ;
entlump = COM_Parse ( entlump ) ;
}
2018-07-22 11:49:37 +00:00
//find targetnames, and store their origins so that we can deal with spotlights.
for ( lmp = entlump ; ; )
{
lmp = COM_Parse ( lmp ) ;
if ( com_token [ 0 ] ! = ' { ' )
break ;
* targetname = 0 ;
VectorClear ( origin ) ;
nest = 1 ;
while ( 1 )
{
lmp = COM_ParseOut ( lmp , key , sizeof ( key ) ) ;
if ( ! lmp )
break ; // error
if ( key [ 0 ] = = ' { ' )
{
nest + + ;
continue ;
}
if ( key [ 0 ] = = ' } ' )
{
nest - - ;
if ( ! nest )
break ; // end of entity
continue ;
}
if ( nest ! = 1 )
continue ;
if ( key [ 0 ] = = ' _ ' )
2021-08-23 06:37:30 +00:00
{
if ( ! strcmp ( key + 1 , " shadowlight " ) )
rerelease = true ;
2018-07-22 11:49:37 +00:00
memmove ( key , key + 1 , strlen ( key ) ) ;
2021-08-23 06:37:30 +00:00
}
2018-07-22 11:49:37 +00:00
while ( key [ strlen ( key ) - 1 ] = = ' ' ) // remove trailing spaces
key [ strlen ( key ) - 1 ] = 0 ;
lmp = COM_ParseOut ( lmp , value , sizeof ( value ) ) ;
if ( ! lmp )
break ; // error
// now that we have the key pair worked out...
if ( ! strcmp ( " targetname " , key ) )
Q_strncpyz ( targetname , value , sizeof ( targetname ) ) ;
else if ( ! strcmp ( " origin " , key ) )
sscanf ( value , " %f %f %f " , & origin [ 0 ] , & origin [ 1 ] , & origin [ 2 ] ) ;
}
//if we found an ent with a targetname and an origin, then record where it was.
if ( * targetname & & ( origin [ 0 ] | | origin [ 1 ] | | origin [ 2 ] ) )
InfoBuf_SetStarKey ( & targets , targetname , va ( " %f %f %f " , origin [ 0 ] , origin [ 1 ] , origin [ 2 ] ) ) ;
}
2021-08-28 07:09:54 +00:00
if ( ! importmode & & ! rerelease )
2022-01-30 05:55:01 +00:00
{
InfoBuf_Clear ( & targets , true ) ;
2021-08-28 07:09:54 +00:00
return false ; //don't make it up from legacy ents.
2022-01-30 05:55:01 +00:00
}
2021-08-28 07:09:54 +00:00
2012-01-01 02:26:42 +00:00
for ( entnum = 0 ; ; entnum + + )
{
entlump = COM_Parse ( entlump ) ;
if ( com_token [ 0 ] ! = ' { ' )
break ;
type = LIGHTTYPE_MINUSX ;
origin [ 0 ] = origin [ 1 ] = origin [ 2 ] = 0 ;
originhack [ 0 ] = originhack [ 1 ] = originhack [ 2 ] = 0 ;
angles [ 0 ] = angles [ 1 ] = angles [ 2 ] = 0 ;
2018-07-22 11:49:37 +00:00
mangle [ 0 ] = mangle [ 1 ] = mangle [ 2 ] = 0 ;
2012-01-01 02:26:42 +00:00
color [ 0 ] = color [ 1 ] = color [ 2 ] = 1 ;
light [ 0 ] = light [ 1 ] = light [ 2 ] = 1 ; light [ 3 ] = 300 ;
overridecolor [ 0 ] = overridecolor [ 1 ] = overridecolor [ 2 ] = 1 ;
fadescale = 1 ;
lightscale = 1 ;
2018-07-22 11:49:37 +00:00
* target = 0 ;
2012-01-01 02:26:42 +00:00
style = 0 ;
skin = 0 ;
pflags = 0 ;
2021-08-23 06:37:30 +00:00
fade [ 0 ] = fade [ 1 ] = 0 ;
2016-07-12 00:40:13 +00:00
VectorSet ( colourscales , r_editlights_import_ambient . value , r_editlights_import_diffuse . value , r_editlights_import_specular . value ) ;
2013-05-11 05:03:07 +00:00
//effects = 0;
2012-01-01 02:26:42 +00:00
islight = false ;
nest = 1 ;
while ( 1 )
{
entlump = COM_Parse ( entlump ) ;
if ( ! entlump )
break ; // error
if ( com_token [ 0 ] = = ' { ' )
{
nest + + ;
continue ;
}
if ( com_token [ 0 ] = = ' } ' )
{
nest - - ;
if ( ! nest )
break ; // end of entity
continue ;
}
if ( nest ! = 1 )
continue ;
if ( com_token [ 0 ] = = ' _ ' )
Q_strncpyz ( key , com_token + 1 , sizeof ( key ) ) ;
else
Q_strncpyz ( key , com_token , sizeof ( key ) ) ;
while ( key [ strlen ( key ) - 1 ] = = ' ' ) // remove trailing spaces
key [ strlen ( key ) - 1 ] = 0 ;
entlump = COM_Parse ( entlump ) ;
if ( ! entlump )
break ; // error
Q_strncpyz ( value , com_token , sizeof ( value ) ) ;
2021-08-23 06:37:30 +00:00
if ( rerelease )
2012-01-01 02:26:42 +00:00
{
2021-08-23 06:37:30 +00:00
if ( ! strcmp ( " color " , key ) )
sscanf ( value , " %f %f %f " , & light [ 0 ] , & light [ 1 ] , & light [ 2 ] ) ;
else if ( ! strcmp ( " shadowlightcull " , key ) )
; //sscanf(value, "%f %f %f", &color[0], &color[1], &color[2]);
else if ( ! strcmp ( " shadowlightresolution " , key ) )
; //sscanf(value, "%f %f %f", &color[0], &color[1], &color[2]);
else if ( ! strcmp ( " shadowlightradius " , key ) )
light [ 3 ] = atof ( value ) ;
else if ( ! strcmp ( " shadowlightstartfadedistance " , key ) )
fade [ 0 ] = atof ( value ) ;
else if ( ! strcmp ( " shadowlightendfadedistance " , key ) )
fade [ 1 ] = atof ( value ) ;
else if ( ! strcmp ( " shadowlightintensity " , key ) )
2012-01-01 02:26:42 +00:00
{
2021-08-23 06:37:30 +00:00
colourscales [ 0 ] * = atof ( value ) ;
colourscales [ 1 ] * = atof ( value ) ;
colourscales [ 2 ] * = atof ( value ) ;
2012-01-01 02:26:42 +00:00
}
2021-08-23 06:37:30 +00:00
else if ( ! strcmp ( " shadowlight " , key ) )
islight = atoi ( value ) ;
else if ( ! strcmp ( " shadowlightstyle " , key ) )
style = atoi ( value ) ;
else if ( ! strcmp ( " shadowlightconeangle " , key ) )
angles [ 1 ] = atof ( value ) * 2 ;
else if ( ! strcmp ( " origin " , key ) )
sscanf ( value , " %f %f %f " , & origin [ 0 ] , & origin [ 1 ] , & origin [ 2 ] ) ;
else if ( ! strcmp ( " target " , key ) )
Q_strncpyz ( target , value , sizeof ( target ) ) ;
2018-07-22 11:49:37 +00:00
}
2021-08-23 06:37:30 +00:00
else
2012-01-01 02:26:42 +00:00
{
2021-08-23 06:37:30 +00:00
// now that we have the key pair worked out...
if ( ! strcmp ( " light " , key ) )
2012-01-01 02:26:42 +00:00
{
2021-08-23 06:37:30 +00:00
n = sscanf ( value , " %f %f %f %f " , & vec [ 0 ] , & vec [ 1 ] , & vec [ 2 ] , & vec [ 3 ] ) ;
if ( n = = 1 )
2012-01-01 02:26:42 +00:00
{
2021-08-23 06:37:30 +00:00
// quake
light [ 0 ] = vec [ 0 ] * ( 1.0f / 256.0f ) ;
light [ 1 ] = vec [ 0 ] * ( 1.0f / 256.0f ) ;
light [ 2 ] = vec [ 0 ] * ( 1.0f / 256.0f ) ;
light [ 3 ] = vec [ 0 ] ;
2012-01-01 02:26:42 +00:00
}
2021-08-23 06:37:30 +00:00
else if ( n = = 4 )
2012-01-01 02:26:42 +00:00
{
2021-08-23 06:37:30 +00:00
// halflife
light [ 0 ] = vec [ 0 ] * ( 1.0f / 255.0f ) ;
light [ 1 ] = vec [ 1 ] * ( 1.0f / 255.0f ) ;
light [ 2 ] = vec [ 2 ] * ( 1.0f / 255.0f ) ;
light [ 3 ] = vec [ 3 ] ;
2012-01-01 02:26:42 +00:00
}
2021-08-23 06:37:30 +00:00
}
else if ( ! strcmp ( " delay " , key ) )
type = atoi ( value ) ;
else if ( ! strcmp ( " origin " , key ) )
sscanf ( value , " %f %f %f " , & origin [ 0 ] , & origin [ 1 ] , & origin [ 2 ] ) ;
else if ( ! strcmp ( " angle " , key ) ) //orientation for cubemaps (or angle of spot lights)
angles [ 0 ] = 0 , angles [ 1 ] = atof ( value ) , angles [ 2 ] = 0 ;
else if ( ! strcmp ( " mangle " , key ) ) //orientation for cubemaps (or angle of spot lights)
{
sscanf ( value , " %f %f %f " , & mangle [ 1 ] , & mangle [ 0 ] , & mangle [ 2 ] ) ; //FIXME: order is fucked.
mangle [ 0 ] = 360 - mangle [ 0 ] ; //FIXME: pitch is fucked too.
}
//_softangle -- the inner cone angle of a spotlight.
else if ( ! strcmp ( " angles " , key ) ) //richer cubemap orientation.
sscanf ( value , " %f %f %f " , & angles [ 0 ] , & angles [ 1 ] , & angles [ 2 ] ) ;
else if ( ! strcmp ( " color " , key ) )
sscanf ( value , " %f %f %f " , & color [ 0 ] , & color [ 1 ] , & color [ 2 ] ) ;
else if ( ! strcmp ( " wait " , key ) )
fadescale = atof ( value ) ;
else if ( ! strcmp ( " target " , key ) )
Q_strncpyz ( target , value , sizeof ( target ) ) ;
else if ( ! strcmp ( " classname " , key ) )
{
if ( ! strncmp ( value , " light " , 5 ) )
2012-01-01 02:26:42 +00:00
{
2021-08-23 06:37:30 +00:00
islight = true ;
if ( ! strcmp ( value , " light_fluoro " ) )
{
originhack [ 0 ] = 0 ;
originhack [ 1 ] = 0 ;
originhack [ 2 ] = 0 ;
overridecolor [ 0 ] = 1 ;
overridecolor [ 1 ] = 1 ;
overridecolor [ 2 ] = 1 ;
}
if ( ! strcmp ( value , " light_fluorospark " ) )
{
originhack [ 0 ] = 0 ;
originhack [ 1 ] = 0 ;
originhack [ 2 ] = 0 ;
overridecolor [ 0 ] = 1 ;
overridecolor [ 1 ] = 1 ;
overridecolor [ 2 ] = 1 ;
}
if ( ! strcmp ( value , " light_globe " ) )
{
originhack [ 0 ] = 0 ;
originhack [ 1 ] = 0 ;
originhack [ 2 ] = 0 ;
overridecolor [ 0 ] = 1 ;
overridecolor [ 1 ] = 0.8 ;
overridecolor [ 2 ] = 0.4 ;
}
if ( ! strcmp ( value , " light_flame_large_yellow " ) )
{
originhack [ 0 ] = 0 ;
originhack [ 1 ] = 0 ;
originhack [ 2 ] = 0 ;
overridecolor [ 0 ] = 1 ;
overridecolor [ 1 ] = 0.5 ;
overridecolor [ 2 ] = 0.1 ;
}
if ( ! strcmp ( value , " light_flame_small_yellow " ) )
{
originhack [ 0 ] = 0 ;
originhack [ 1 ] = 0 ;
originhack [ 2 ] = 0 ;
overridecolor [ 0 ] = 1 ;
overridecolor [ 1 ] = 0.5 ;
overridecolor [ 2 ] = 0.1 ;
}
if ( ! strcmp ( value , " light_torch_small_white " ) )
{
originhack [ 0 ] = 0 ;
originhack [ 1 ] = 0 ;
originhack [ 2 ] = 0 ;
overridecolor [ 0 ] = 1 ;
overridecolor [ 1 ] = 0.5 ;
overridecolor [ 2 ] = 0.1 ;
}
if ( ! strcmp ( value , " light_torch_small_walltorch " ) )
{
originhack [ 0 ] = 0 ;
originhack [ 1 ] = 0 ;
originhack [ 2 ] = 0 ;
overridecolor [ 0 ] = 1 ;
overridecolor [ 1 ] = 0.5 ;
overridecolor [ 2 ] = 0.1 ;
}
2012-01-01 02:26:42 +00:00
}
}
2021-08-23 06:37:30 +00:00
else if ( ! strcmp ( " style " , key ) )
style = atoi ( value ) ;
else if ( ! strcmp ( " skin " , key ) )
skin = ( int ) atof ( value ) ;
else if ( ! strcmp ( " pflags " , key ) )
pflags = ( int ) atof ( value ) ;
//else if (!strcmp("effects", key))
//effects = (int)atof(value);
else if ( ! strcmp ( " scale " , key ) )
lightscale = atof ( value ) ;
else if ( ! strcmp ( " fade " , key ) )
fadescale = atof ( value ) ;
2012-01-01 02:26:42 +00:00
2016-07-12 00:40:13 +00:00
# ifdef MAP_PROC
2021-08-23 06:37:30 +00:00
else if ( ! strcmp ( " nodynamicshadows " , key ) ) //doom3
;
else if ( ! strcmp ( " noshadows " , key ) ) //doom3
{
if ( atof ( value ) )
pflags | = PFLAGS_NOSHADOW ;
}
else if ( ! strcmp ( " nospecular " , key ) ) //doom3
{
if ( atof ( value ) )
colourscales [ 2 ] = 0 ;
}
else if ( ! strcmp ( " nodiffuse " , key ) ) //doom3
{
if ( atof ( value ) )
colourscales [ 1 ] = 0 ;
}
2016-07-12 00:40:13 +00:00
# endif
2021-08-23 06:37:30 +00:00
else if ( ! strcmp ( " light_radius " , key ) )
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
{
2021-08-23 06:37:30 +00:00
light [ 0 ] = 1 ;
light [ 1 ] = 1 ;
light [ 2 ] = 1 ;
light [ 3 ] = atof ( value ) ;
}
else if ( entnum = = 0 & & ! strcmp ( " noautolight " , key ) )
{
//tenebrae compat. don't generate rtlights automagically if the world entity specifies this.
if ( atoi ( value ) )
{
okay = true ;
2022-01-30 05:55:01 +00:00
InfoBuf_Clear ( & targets , true ) ;
2021-08-23 06:37:30 +00:00
return okay ;
}
}
else if ( entnum = = 0 & & ! strcmp ( " lightmapbright " , key ) )
{
//tenebrae compat. this overrides r_shadow_realtime_world_lightmap
2021-08-28 07:09:54 +00:00
r_shadow_realtime_world_lightmaps_force = atof ( value ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
}
2016-08-25 00:12:14 +00:00
}
2012-01-01 02:26:42 +00:00
}
if ( ! islight )
continue ;
if ( lightscale < = 0 )
lightscale = 1 ;
if ( fadescale < = 0 )
fadescale = 1 ;
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
if ( color [ 0 ] > = 16 | | color [ 1 ] > = 16 | | color [ 2 ] > = 16 ) //_color 255 255 255 should be identity, not super-oversaturated.
VectorScale ( color , 1 / 255.0 , color ) ; //if only there were standards for this sort of thing.
2012-01-01 02:26:42 +00:00
if ( color [ 0 ] = = color [ 1 ] & & color [ 0 ] = = color [ 2 ] )
{
color [ 0 ] * = overridecolor [ 0 ] ;
color [ 1 ] * = overridecolor [ 1 ] ;
color [ 2 ] * = overridecolor [ 2 ] ;
}
2012-12-04 19:37:57 +00:00
radius = light [ 3 ] * r_editlights_import_radius . value * lightscale / fadescale ;
2012-01-01 02:26:42 +00:00
color [ 0 ] = color [ 0 ] * light [ 0 ] ;
color [ 1 ] = color [ 1 ] * light [ 1 ] ;
color [ 2 ] = color [ 2 ] * light [ 2 ] ;
2018-07-22 11:49:37 +00:00
# define CUTOFF (128.0 / 255)
2012-01-01 02:26:42 +00:00
switch ( type )
{
case LIGHTTYPE_MINUSX :
break ;
case LIGHTTYPE_RECIPX :
2018-07-22 11:49:37 +00:00
# if 1
2012-01-01 02:26:42 +00:00
radius * = 2 ;
2018-07-22 11:49:37 +00:00
// VectorScale(color, (1.0f / 16.0f), color);
# else
//light util uses something like: cutoff == light/((scaledist*fadescale*radius)/128)
//radius = light/(cutoff*128*scaledist*fadescale)
radius = lightscale * r_editlights_import_radius . value * 256 / ( 1 * fadescale ) ;
radius = min ( radius , 300 ) ;
VectorScale ( color , 255 / light [ 3 ] , color ) ;
# endif
2012-01-01 02:26:42 +00:00
break ;
case LIGHTTYPE_RECIPXX :
2018-07-22 11:49:37 +00:00
case LIGHTTYPE_RECIPXX2 :
# if 1
2012-01-01 02:26:42 +00:00
radius * = 2 ;
2018-07-22 11:49:37 +00:00
// VectorScale(color, (1.0f / 16.0f), color);
# else
//light util uses something like: cutoff == light/((scaledist*scaledist*fadescale*fadescale*radius*radius)/(128*128))
radius = lightscale * r_editlights_import_radius . value * sqrt ( 1 / CUTOFF * 128 * 128 * 1 * 1 * fadescale * fadescale ) ;
radius = min ( radius , 300 ) ;
VectorScale ( color , 255 / light [ 3 ] , color ) ;
# endif
2012-01-01 02:26:42 +00:00
break ;
default :
2018-07-22 11:49:37 +00:00
case LIGHTTYPE_INFINITE :
radius = FLT_MAX ; //close enough
2012-01-01 02:26:42 +00:00
break ;
2018-07-22 11:49:37 +00:00
case LIGHTTYPE_LOCALMIN : //can't support, treat like LIGHTTYPE_MINUSX
2012-01-01 02:26:42 +00:00
break ;
2018-07-22 11:49:37 +00:00
case LIGHTTYPE_SUN :
2012-01-01 02:26:42 +00:00
break ;
}
2018-07-22 11:49:37 +00:00
2021-08-24 06:06:05 +00:00
if ( rerelease )
2021-08-28 07:09:54 +00:00
r_shadow_realtime_world_lightmaps_force = 1 ;
2021-08-24 06:06:05 +00:00
else if ( radius < 50 ) //some mappers insist on many tiny lights. such lights can usually get away with no shadows..
2018-07-22 11:49:37 +00:00
pflags | = PFLAGS_NOSHADOW ;
2012-01-01 02:26:42 +00:00
VectorAdd ( origin , originhack , origin ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
if ( radius > = 1 & & ! ( cl . worldmodel - > funcs . PointContents ( cl . worldmodel , NULL , origin ) & FTECONTENTS_SOLID ) )
2012-01-01 02:26:42 +00:00
{
dlight_t * dl = CL_AllocSlight ( ) ;
if ( ! dl )
break ;
2018-07-22 11:49:37 +00:00
2012-01-01 02:26:42 +00:00
VectorCopy ( origin , dl - > origin ) ;
2018-11-19 06:37:25 +00:00
VectorCopy ( angles , dl - > angles ) ;
AngleVectors ( dl - > angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
2013-10-29 17:38:22 +00:00
VectorInverse ( dl - > axis [ 1 ] ) ;
2012-01-01 02:26:42 +00:00
dl - > radius = radius ;
VectorCopy ( color , dl - > color ) ;
dl - > flags = 0 ;
dl - > flags | = LFLAG_REALTIMEMODE ;
dl - > flags | = ( pflags & PFLAGS_CORONA ) ? LFLAG_FLASHBLEND : 0 ;
dl - > flags | = ( pflags & PFLAGS_NOSHADOW ) ? LFLAG_NOSHADOWS : 0 ;
2019-09-10 15:40:04 +00:00
dl - > style = style ;
2021-08-23 06:37:30 +00:00
dl - > fade [ 0 ] = fade [ 0 ] ;
dl - > fade [ 1 ] = fade [ 1 ] ;
2016-07-12 00:40:13 +00:00
VectorCopy ( colourscales , dl - > lightcolourscales ) ;
2018-07-22 11:49:37 +00:00
//handle spotlights.
if ( mangle [ 0 ] | | mangle [ 1 ] | | mangle [ 2 ] )
{
dl - > fov = angles [ 1 ] ;
if ( ! dl - > fov ) //default is 40, supposedly
dl - > fov = 40 ;
2018-11-19 06:37:25 +00:00
VectorCopy ( mangle , dl - > angles ) ;
AngleVectors ( dl - > angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
2018-07-22 11:49:37 +00:00
VectorInverse ( dl - > axis [ 1 ] ) ;
}
else if ( * target )
{
lmp = InfoBuf_ValueForKey ( & targets , target ) ;
if ( * lmp )
{
dl - > fov = angles [ 1 ] ;
if ( ! dl - > fov ) //default is 40, supposedly
dl - > fov = 40 ;
sscanf ( lmp , " %f %f %f " , & angles [ 0 ] , & angles [ 1 ] , & angles [ 2 ] ) ;
VectorSubtract ( angles , origin , dl - > axis [ 0 ] ) ;
VectorNormalize ( dl - > axis [ 0 ] ) ;
VectorVectors ( dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorInverse ( dl - > axis [ 1 ] ) ;
//we don't have any control over the inner cone.
2018-11-19 06:37:25 +00:00
//so queries work properly
VectorAngles ( dl - > axis [ 0 ] , dl - > axis [ 2 ] , dl - > angles , false ) ;
dl - > angles [ 0 ] = anglemod ( dl - > angles [ 0 ] ) ;
2018-07-22 11:49:37 +00:00
}
}
2013-05-11 05:03:07 +00:00
if ( skin > = 16 )
2014-10-05 20:04:11 +00:00
R_LoadNumberedLightTexture ( dl , skin ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
okay = true ;
2012-01-01 02:26:42 +00:00
}
}
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
2018-07-22 11:49:37 +00:00
InfoBuf_Clear ( & targets , true ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
return okay ;
2012-01-01 02:26:42 +00:00
}
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
qboolean R_LoadRTLights ( void )
2012-01-01 02:26:42 +00:00
{
dlight_t * dl ;
char fname [ MAX_QPATH ] ;
char cubename [ MAX_QPATH ] ;
2018-11-19 06:37:25 +00:00
char customstyle [ 1024 ] ;
2012-01-01 02:26:42 +00:00
char * file ;
char * end ;
int style ;
vec3_t org ;
float radius ;
vec3_t rgb ;
2014-10-05 20:04:11 +00:00
vec3_t avel ;
2019-04-01 10:16:36 +00:00
float fov , nearclip ;
2012-01-01 02:26:42 +00:00
unsigned int flags ;
float coronascale ;
float corona ;
float ambientscale , diffusescale , specularscale ;
vec3_t angles ;
2021-08-23 06:37:30 +00:00
float fade [ 2 ] ;
2012-01-01 02:26:42 +00:00
//delete all old lights, even dynamic ones
rtlights_first = RTL_FIRST ;
rtlights_max = RTL_FIRST ;
COM_StripExtension ( cl . worldmodel - > name , fname , sizeof ( fname ) ) ;
strncat ( fname , " .rtlights " , MAX_QPATH - 1 ) ;
2018-07-05 16:21:44 +00:00
file = COM_LoadTempFile ( fname , 0 , NULL ) ;
2012-01-01 02:26:42 +00:00
if ( file )
while ( 1 )
{
end = strchr ( file , ' \n ' ) ;
if ( ! end )
end = file + strlen ( file ) ;
if ( end = = file )
break ;
* end = ' \0 ' ;
while ( * file = = ' ' | | * file = = ' \t ' )
file + + ;
2016-08-25 00:12:14 +00:00
if ( * file = = ' # ' )
{
file + + ;
while ( * file = = ' ' | | * file = = ' \t ' )
file + + ;
file = COM_Parse ( file ) ;
if ( ! Q_strcasecmp ( com_token , " lightmaps " ) )
{
file = COM_Parse ( file ) ;
//foo = atoi(com_token);
}
else
Con_DPrintf ( " Unknown directive: %s \n " , com_token ) ;
file = end + 1 ;
continue ;
}
else if ( * file = = ' ! ' )
2012-01-01 02:26:42 +00:00
{
flags = LFLAG_NOSHADOWS ;
file + + ;
}
else
flags = 0 ;
file = COM_Parse ( file ) ;
org [ 0 ] = atof ( com_token ) ;
file = COM_Parse ( file ) ;
org [ 1 ] = atof ( com_token ) ;
file = COM_Parse ( file ) ;
org [ 2 ] = atof ( com_token ) ;
file = COM_Parse ( file ) ;
radius = atof ( com_token ) ;
file = COM_Parse ( file ) ;
rgb [ 0 ] = file ? atof ( com_token ) : 1 ;
file = COM_Parse ( file ) ;
rgb [ 1 ] = file ? atof ( com_token ) : 1 ;
file = COM_Parse ( file ) ;
rgb [ 2 ] = file ? atof ( com_token ) : 1 ;
file = COM_Parse ( file ) ;
style = file ? atof ( com_token ) : 0 ;
file = COM_Parse ( file ) ;
//cubemap
Q_strncpyz ( cubename , com_token , sizeof ( cubename ) ) ;
file = COM_Parse ( file ) ;
//corona
corona = file ? atof ( com_token ) : 0 ;
file = COM_Parse ( file ) ;
angles [ 0 ] = file ? atof ( com_token ) : 0 ;
file = COM_Parse ( file ) ;
angles [ 1 ] = file ? atof ( com_token ) : 0 ;
file = COM_Parse ( file ) ;
angles [ 2 ] = file ? atof ( com_token ) : 0 ;
file = COM_Parse ( file ) ;
2014-10-05 20:04:11 +00:00
//corona scale
2012-01-01 02:26:42 +00:00
coronascale = file ? atof ( com_token ) : 0.25 ;
file = COM_Parse ( file ) ;
//ambient
ambientscale = file ? atof ( com_token ) : 0 ;
file = COM_Parse ( file ) ;
//diffuse
diffusescale = file ? atof ( com_token ) : 1 ;
file = COM_Parse ( file ) ;
//specular
specularscale = file ? atof ( com_token ) : 1 ;
file = COM_Parse ( file ) ;
flags | = file ? atoi ( com_token ) : LFLAG_REALTIMEMODE ;
2021-08-23 06:37:30 +00:00
nearclip = fov = avel [ 0 ] = avel [ 1 ] = avel [ 2 ] = fade [ 0 ] = fade [ 1 ] = 0 ;
2018-11-19 06:37:25 +00:00
* customstyle = 0 ;
2014-10-05 20:04:11 +00:00
while ( file )
{
file = COM_Parse ( file ) ;
if ( ! strncmp ( com_token , " rotx= " , 5 ) )
avel [ 0 ] = file ? atof ( com_token + 5 ) : 0 ;
else if ( ! strncmp ( com_token , " roty= " , 5 ) )
avel [ 1 ] = file ? atof ( com_token + 5 ) : 0 ;
else if ( ! strncmp ( com_token , " rotz= " , 5 ) )
avel [ 2 ] = file ? atof ( com_token + 5 ) : 0 ;
else if ( ! strncmp ( com_token , " fov= " , 4 ) )
fov = file ? atof ( com_token + 4 ) : 0 ;
2021-08-23 06:37:30 +00:00
else if ( ! strncmp ( com_token , " fademin= " , 8 ) )
fade [ 0 ] = file ? atof ( com_token + 8 ) : 0 ;
else if ( ! strncmp ( com_token , " fademax= " , 8 ) )
fade [ 1 ] = file ? atof ( com_token + 4 ) : 0 ;
2019-04-01 10:16:36 +00:00
else if ( ! strncmp ( com_token , " nearclip= " , 9 ) )
nearclip = file ? atof ( com_token + 9 ) : 0 ;
2018-11-19 06:37:25 +00:00
else if ( ! strncmp ( com_token , " nostencil= " , 10 ) )
flags | = atoi ( com_token + 10 ) ? LFLAG_SHADOWMAP : 0 ;
else if ( ! strncmp ( com_token , " crepuscular= " , 12 ) )
flags | = atoi ( com_token + 12 ) ? LFLAG_CREPUSCULAR : 0 ;
else if ( ! strncmp ( com_token , " ortho= " , 6 ) )
flags | = atoi ( com_token + 6 ) ? LFLAG_ORTHO : 0 ;
else if ( ! strncmp ( com_token , " stylestring= " , 12 ) )
Q_strncpyz ( customstyle , com_token + 12 , sizeof ( customstyle ) ) ;
else if ( file )
Con_DPrintf ( " Unknown .rtlights arg \" %s \" \n " , com_token ) ;
2014-10-05 20:04:11 +00:00
}
2012-01-01 02:26:42 +00:00
if ( radius )
{
dl = CL_AllocSlight ( ) ;
if ( ! dl )
break ;
VectorCopy ( org , dl - > origin ) ;
dl - > radius = radius ;
VectorCopy ( rgb , dl - > color ) ;
dl - > corona = corona ;
dl - > coronascale = coronascale ;
dl - > die = 0 ;
dl - > flags = flags ;
2014-10-05 20:04:11 +00:00
dl - > fov = fov ;
2019-04-01 10:16:36 +00:00
dl - > nearclip = nearclip ;
2012-07-05 19:42:36 +00:00
dl - > lightcolourscales [ 0 ] = ambientscale ;
dl - > lightcolourscales [ 1 ] = diffusescale ;
dl - > lightcolourscales [ 2 ] = specularscale ;
2021-08-23 06:37:30 +00:00
dl - > fade [ 0 ] = fade [ 0 ] ;
dl - > fade [ 1 ] = fade [ 1 ] ;
2014-10-05 20:04:11 +00:00
AngleVectorsFLU ( angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorCopy ( avel , dl - > rotation ) ;
2012-01-01 02:26:42 +00:00
Q_strncpyz ( dl - > cubemapname , cubename , sizeof ( dl - > cubemapname ) ) ;
if ( * dl - > cubemapname )
2019-10-18 08:37:38 +00:00
dl - > cubetexture = R_LoadReplacementTexture ( dl - > cubemapname , " " , IF_TEXTYPE_CUBE , NULL , 0 , 0 , TF_INVALID ) ;
2012-01-01 02:26:42 +00:00
else
dl - > cubetexture = r_nulltex ;
2019-09-10 15:40:04 +00:00
dl - > style = style ;
2018-11-19 06:37:25 +00:00
dl - > customstyle = ( * customstyle ) ? Z_StrDup ( customstyle ) : NULL ;
2012-01-01 02:26:42 +00:00
}
file = end + 1 ;
}
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
return ! ! file ;
2012-01-01 02:26:42 +00:00
}
2018-11-19 06:37:25 +00:00
static void R_SaveRTLights_f ( void )
2012-01-01 02:26:42 +00:00
{
dlight_t * light ;
vfsfile_t * f ;
unsigned int i ;
char fname [ MAX_QPATH ] ;
2013-11-21 23:02:28 +00:00
char sysname [ MAX_OSPATH ] ;
2012-01-01 02:26:42 +00:00
vec3_t ang ;
2018-11-19 06:37:25 +00:00
int ver = 0 ;
2012-01-01 02:26:42 +00:00
COM_StripExtension ( cl . worldmodel - > name , fname , sizeof ( fname ) ) ;
strncat ( fname , " .rtlights " , MAX_QPATH - 1 ) ;
FS_CreatePath ( fname , FS_GAMEONLY ) ;
f = FS_OpenVFS ( fname , " wb " , FS_GAMEONLY ) ;
if ( ! f )
{
Con_Printf ( " couldn't open %s \n " , fname ) ;
return ;
}
2016-08-25 00:12:14 +00:00
// VFS_PUTS(f, va("#lightmap %f\n", foo));
2012-01-01 02:26:42 +00:00
for ( light = cl_dlights + rtlights_first , i = rtlights_first ; i < rtlights_max ; i + + , light + + )
{
if ( light - > die )
continue ;
if ( ! light - > radius )
continue ;
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
VectorAngles ( light - > axis [ 0 ] , light - > axis [ 2 ] , ang , false ) ;
2018-11-19 06:37:25 +00:00
//the .rtlights format is defined by DP, the first few parts cannot be changed without breaking wider compat.
//it got extended a few times. only write what we need for greater compat, just in case.
if ( ( light - > flags & ( LFLAG_SHADOWMAP | LFLAG_CREPUSCULAR | LFLAG_ORTHO ) ) | | light - > rotation [ 0 ] | | light - > rotation [ 1 ] | | light - > rotation [ 2 ] | | light - > fov | | light - > customstyle )
ver = 2 ; //one of our own flags. always spew the full DP stuff to try to avoid confusion
else if ( light - > coronascale ! = 0.25 | | light - > lightcolourscales [ 0 ] ! = 0 | | light - > lightcolourscales [ 1 ] ! = 1 | | light - > lightcolourscales [ 2 ] ! = 1 | | ( light - > flags & ~ LFLAG_NOSHADOWS ) ! = LFLAG_REALTIMEMODE )
ver = 2 ;
else if ( * light - > cubemapname | | light - > corona | | ang [ 0 ] | | ang [ 1 ] | | ang [ 2 ] )
ver = 1 ;
else
ver = 0 ;
VFS_PRINTF ( f ,
2012-01-01 02:26:42 +00:00
" %s%f %f %f "
" %f %f %f %f "
2018-11-19 06:37:25 +00:00
" %i " ,
2012-01-01 02:26:42 +00:00
( light - > flags & LFLAG_NOSHADOWS ) ? " ! " : " " , light - > origin [ 0 ] , light - > origin [ 1 ] , light - > origin [ 2 ] ,
2018-11-19 06:37:25 +00:00
light - > radius , light - > color [ 0 ] , light - > color [ 1 ] , light - > color [ 2 ] ,
2019-09-10 15:40:04 +00:00
light - > style ) ;
2018-11-19 06:37:25 +00:00
if ( ver > 0 )
VFS_PRINTF ( f , " \" %s \" %f %f %f %f " , light - > cubemapname , light - > corona , ang [ 0 ] , ang [ 1 ] , ang [ 2 ] ) ;
if ( ver > 1 )
VFS_PRINTF ( f , " %f %f %f %f %i " , light - > coronascale , light - > lightcolourscales [ 0 ] , light - > lightcolourscales [ 1 ] , light - > lightcolourscales [ 2 ] , light - > flags & ( LFLAG_NORMALMODE | LFLAG_REALTIMEMODE ) ) ;
//our weird flags
if ( light - > flags & LFLAG_SHADOWMAP )
VFS_PRINTF ( f , " nostencil=1 " ) ;
if ( light - > flags & LFLAG_CREPUSCULAR )
VFS_PRINTF ( f , " crepuscular=1 " ) ;
if ( light - > flags & LFLAG_ORTHO )
VFS_PRINTF ( f , " ortho=1 " ) ;
//spinning lights (for cubemaps)
if ( light - > rotation [ 0 ] | | light - > rotation [ 1 ] | | light - > rotation [ 2 ] )
VFS_PRINTF ( f , " rotx=%g roty=%g rotz=%g " , light - > rotation [ 0 ] , light - > rotation [ 1 ] , light - > rotation [ 2 ] ) ;
//spotlights
if ( light - > fov )
VFS_PRINTF ( f , " fov=%g " , light - > fov ) ; //aka: outer cone
2019-04-01 10:16:36 +00:00
if ( light - > nearclip )
VFS_PRINTF ( f , " nearclip=%g " , light - > nearclip ) ; //aka: distance into a wall, for lights that are meant to appear to come from a texture
2018-11-19 06:37:25 +00:00
if ( light - > customstyle )
VFS_PRINTF ( f , " \" stylestring=%s \" " , light - > customstyle ) ; //aka: outer cone
2021-08-23 06:37:30 +00:00
if ( light - > fade [ 1 ] > 0 )
VFS_PRINTF ( f , " \" fademin=%g \" \" fademax=%g \" " , light - > fade [ 0 ] , light - > fade [ 1 ] ) ;
2018-11-19 06:37:25 +00:00
VFS_PUTS ( f , " \n " ) ;
2012-01-01 02:26:42 +00:00
}
VFS_CLOSE ( f ) ;
2013-11-21 23:02:28 +00:00
FS_NativePath ( fname , FS_GAMEONLY , sysname , sizeof ( sysname ) ) ;
Con_Printf ( " rtlights saved to %s \n " , sysname ) ;
2012-01-01 02:26:42 +00:00
}
2014-10-05 20:04:11 +00:00
void R_StaticEntityToRTLight ( int i )
{
entity_state_t * state = & cl_static_entities [ i ] . state ;
dlight_t * dl ;
if ( ! ( state - > lightpflags & ( PFLAGS_FULLDYNAMIC | PFLAGS_CORONA ) ) )
return ;
dl = CL_AllocSlight ( ) ;
if ( ! dl )
return ;
VectorCopy ( state - > origin , dl - > origin ) ;
AngleVectors ( state - > angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorInverse ( dl - > axis [ 1 ] ) ;
dl - > radius = state - > light [ 3 ] ;
if ( ! dl - > radius )
dl - > radius = 350 ;
VectorScale ( state - > light , 1.0 / 1024 , dl - > color ) ;
if ( ! state - > light [ 0 ] & & ! state - > light [ 1 ] & & ! state - > light [ 2 ] )
VectorSet ( dl - > color , 1 , 1 , 1 ) ;
dl - > flags = 0 ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
dl - > flags | = LFLAG_NORMALMODE | LFLAG_REALTIMEMODE ;
2014-10-05 20:04:11 +00:00
dl - > flags | = ( state - > lightpflags & PFLAGS_NOSHADOW ) ? LFLAG_NOSHADOWS : 0 ;
if ( state - > lightpflags & PFLAGS_CORONA )
dl - > corona = 1 ;
2019-09-10 15:40:04 +00:00
dl - > style = state - > lightstyle ;
2014-10-05 20:04:11 +00:00
if ( state - > lightpflags & PFLAGS_FULLDYNAMIC )
{
dl - > lightcolourscales [ 0 ] = r_editlights_import_ambient . value ;
dl - > lightcolourscales [ 1 ] = r_editlights_import_diffuse . value ;
dl - > lightcolourscales [ 2 ] = r_editlights_import_specular . value ;
}
else
{ //corona-only light
dl - > lightcolourscales [ 0 ] = 0 ;
dl - > lightcolourscales [ 1 ] = 0 ;
dl - > lightcolourscales [ 2 ] = 0 ;
}
if ( state - > skinnum > = 16 )
R_LoadNumberedLightTexture ( dl , state - > skinnum ) ;
}
2018-11-19 06:37:25 +00:00
static void R_ReloadRTLights_f ( void )
2012-01-01 02:26:42 +00:00
{
2014-10-05 20:04:11 +00:00
int i ;
2012-01-01 02:26:42 +00:00
if ( ! cl . worldmodel )
{
Con_Printf ( " Cannot reload lights at this time \n " ) ;
return ;
}
rtlights_first = RTL_FIRST ;
rtlights_max = RTL_FIRST ;
2021-08-28 07:09:54 +00:00
r_shadow_realtime_world_lightmaps_force = - 1 ;
2012-01-01 02:26:42 +00:00
if ( ! strcmp ( Cmd_Argv ( 1 ) , " bsp " ) )
2021-08-28 07:09:54 +00:00
R_ImportRTLights ( Mod_GetEntitiesString ( cl . worldmodel ) , 1 ) ;
2012-01-01 02:26:42 +00:00
else if ( ! strcmp ( Cmd_Argv ( 1 ) , " rtlights " ) )
R_LoadRTLights ( ) ;
2018-11-19 06:37:25 +00:00
else if ( ! strcmp ( Cmd_Argv ( 1 ) , " statics " ) )
{
for ( i = 0 ; i < cl . num_statics ; i + + )
R_StaticEntityToRTLight ( i ) ;
}
2017-04-18 11:12:17 +00:00
else if ( ! strcmp ( Cmd_Argv ( 1 ) , " none " ) )
;
else
2012-01-01 02:26:42 +00:00
{
2018-11-19 06:37:25 +00:00
//try to load .rtlights file
if ( rtlights_first = = rtlights_max )
R_LoadRTLights ( ) ;
//if there's a static entity with rtlights set, then assume the mod is taking care of it for us.
if ( rtlights_first = = rtlights_max )
for ( i = 0 ; i < cl . num_statics ; i + + )
R_StaticEntityToRTLight ( i ) ;
//otherwise try to import.
2012-01-01 02:26:42 +00:00
if ( rtlights_first = = rtlights_max )
2021-08-28 07:09:54 +00:00
R_ImportRTLights ( Mod_GetEntitiesString ( cl . worldmodel ) , r_shadow_realtime_world_importlightentitiesfrommap . ival ) ;
2012-01-01 02:26:42 +00:00
}
2021-08-28 07:09:54 +00:00
if ( r_shadow_realtime_world_lightmaps_force > = 0 )
r_shadow_realtime_world_lightmaps . value = r_shadow_realtime_world_lightmaps_force ;
else
r_shadow_realtime_world_lightmaps . value = atof ( r_shadow_realtime_world_lightmaps . string ) ;
2018-11-19 06:37:25 +00:00
}
//-1 for arg error
static int R_EditLight ( dlight_t * dl , const char * cmd , int argc , const char * x , const char * y , const char * z )
{
if ( argc = = 1 )
{
y = x ;
z = x ;
}
if ( ! strcmp ( cmd , " origin " ) )
{
dl - > origin [ 0 ] = atof ( x ) ;
dl - > origin [ 1 ] = atof ( y ) ;
dl - > origin [ 2 ] = atof ( z ) ;
}
else if ( ! strcmp ( cmd , " originscale " ) )
{
dl - > origin [ 0 ] * = atof ( x ) ;
dl - > origin [ 1 ] * = atof ( y ) ;
dl - > origin [ 2 ] * = atof ( z ) ;
}
else if ( ! strcmp ( cmd , " originx " ) )
dl - > origin [ 0 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " originy " ) )
dl - > origin [ 1 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " originz " ) )
dl - > origin [ 2 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " move " ) )
{
dl - > origin [ 0 ] + = atof ( x ) ;
dl - > origin [ 1 ] + = atof ( y ) ;
dl - > origin [ 2 ] + = atof ( z ) ;
}
else if ( ! strcmp ( cmd , " movex " ) )
dl - > origin [ 0 ] + = atof ( x ) ;
else if ( ! strcmp ( cmd , " movey " ) )
dl - > origin [ 1 ] + = atof ( x ) ;
else if ( ! strcmp ( cmd , " movez " ) )
dl - > origin [ 2 ] + = atof ( x ) ;
else if ( ! strcmp ( cmd , " angles " ) )
{
dl - > angles [ 0 ] = atof ( x ) ;
dl - > angles [ 1 ] = atof ( y ) ;
dl - > angles [ 2 ] = atof ( z ) ;
AngleVectors ( dl - > angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorInverse ( dl - > axis [ 1 ] ) ;
}
else if ( ! strcmp ( cmd , " anglesx " ) )
{
dl - > angles [ 0 ] = atof ( x ) ;
AngleVectors ( dl - > angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorInverse ( dl - > axis [ 1 ] ) ;
}
else if ( ! strcmp ( cmd , " anglesy " ) )
{
dl - > angles [ 1 ] = atof ( x ) ;
AngleVectors ( dl - > angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorInverse ( dl - > axis [ 1 ] ) ;
}
else if ( ! strcmp ( cmd , " anglesz " ) )
{
dl - > angles [ 2 ] = atof ( x ) ;
AngleVectors ( dl - > angles , dl - > axis [ 0 ] , dl - > axis [ 1 ] , dl - > axis [ 2 ] ) ;
VectorInverse ( dl - > axis [ 1 ] ) ;
}
else if ( ! strcmp ( cmd , " avel " ) )
{
dl - > rotation [ 0 ] = atof ( x ) ;
dl - > rotation [ 1 ] = atof ( y ) ;
dl - > rotation [ 2 ] = atof ( z ) ;
}
else if ( ! strcmp ( cmd , " avelx " ) )
dl - > rotation [ 0 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " avey " ) )
dl - > rotation [ 1 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " avelz " ) )
dl - > rotation [ 2 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " outercone " ) | | ! strcmp ( cmd , " fov " ) )
dl - > fov = atof ( x ) ;
2019-04-01 10:16:36 +00:00
else if ( ! strcmp ( cmd , " nearclip " ) )
dl - > nearclip = atof ( x ) ;
2018-11-19 06:37:25 +00:00
else if ( ! strcmp ( cmd , " color " ) | | ! strcmp ( cmd , " colour " ) )
{
dl - > color [ 0 ] = atof ( x ) ;
dl - > color [ 1 ] = atof ( y ) ;
dl - > color [ 2 ] = atof ( z ) ;
}
else if ( ! strcmp ( cmd , " colorscale " ) | | ! strcmp ( cmd , " colourscale " ) )
{
dl - > color [ 0 ] * = atof ( x ) ;
dl - > color [ 1 ] * = atof ( y ) ;
dl - > color [ 2 ] * = atof ( z ) ;
}
else if ( ! strcmp ( cmd , " radius " ) )
dl - > radius = atof ( x ) ;
else if ( ! strcmp ( cmd , " radiusscale " ) | | ! strcmp ( cmd , " sizescale " ) )
dl - > radius * = atof ( x ) ;
else if ( ! strcmp ( cmd , " style " ) )
2019-09-10 15:40:04 +00:00
dl - > style = atoi ( x ) ;
2018-11-19 06:37:25 +00:00
else if ( ! strcmp ( cmd , " stylestring " ) )
{
Z_Free ( dl - > customstyle ) ;
dl - > customstyle = x ? Z_StrDup ( x ) : NULL ;
}
else if ( ! strcmp ( cmd , " cubemap " ) )
{
Q_strncpyz ( dl - > cubemapname , x , sizeof ( dl - > cubemapname ) ) ;
if ( * dl - > cubemapname )
2019-10-18 08:37:38 +00:00
dl - > cubetexture = R_LoadReplacementTexture ( dl - > cubemapname , " " , IF_TEXTYPE_CUBE , NULL , 0 , 0 , TF_INVALID ) ;
2018-11-19 06:37:25 +00:00
else
dl - > cubetexture = r_nulltex ;
}
else if ( ! strcmp ( cmd , " shadows " ) )
dl - > flags = ( dl - > flags & ~ LFLAG_NOSHADOWS ) | ( ( * x = = ' y ' | | * x = = ' Y ' | | * x = = ' t ' | | atoi ( x ) ) ? 0 : LFLAG_NOSHADOWS ) ;
else if ( ! strcmp ( cmd , " nostencil " ) )
dl - > flags = ( dl - > flags & ~ LFLAG_SHADOWMAP ) | ( ( * x = = ' y ' | | * x = = ' Y ' | | * x = = ' t ' | | atoi ( x ) ) ? 0 : LFLAG_SHADOWMAP ) ;
else if ( ! strcmp ( cmd , " crepuscular " ) )
dl - > flags = ( dl - > flags & ~ LFLAG_CREPUSCULAR ) | ( ( * x = = ' y ' | | * x = = ' Y ' | | * x = = ' t ' | | atoi ( x ) ) ? LFLAG_CREPUSCULAR : 0 ) ;
else if ( ! strcmp ( cmd , " ortho " ) )
dl - > flags = ( dl - > flags & ~ LFLAG_ORTHO ) | ( ( * x = = ' y ' | | * x = = ' Y ' | | * x = = ' t ' | | atoi ( x ) ) ? LFLAG_ORTHO : 0 ) ;
else if ( ! strcmp ( cmd , " corona " ) )
dl - > corona = atof ( x ) ;
else if ( ! strcmp ( cmd , " coronasize " ) )
dl - > coronascale = atof ( x ) ;
else if ( ! strcmp ( cmd , " ambient " ) )
dl - > lightcolourscales [ 0 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " diffuse " ) )
dl - > lightcolourscales [ 1 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " specular " ) )
dl - > lightcolourscales [ 2 ] = atof ( x ) ;
else if ( ! strcmp ( cmd , " normalmode " ) )
dl - > flags = ( dl - > flags & ~ LFLAG_NORMALMODE ) | ( ( * x = = ' y ' | | * x = = ' Y ' | | * x = = ' t ' | | atoi ( x ) ) ? LFLAG_NORMALMODE : 0 ) ;
else if ( ! strcmp ( cmd , " realtimemode " ) )
dl - > flags = ( dl - > flags & ~ LFLAG_REALTIMEMODE ) | ( ( * x = = ' y ' | | * x = = ' Y ' | | * x = = ' t ' | | atoi ( x ) ) ? LFLAG_REALTIMEMODE : 0 ) ;
else
return - 2 ;
dl - > rebuildcache = true ; //mneh, lets just flag it for everything.
return 1 ;
}
void R_EditLights_DrawInfo ( void )
{
float fontscale [ 2 ] = { 8 , 8 } ;
float x = vid . width - 320 ;
float y = 0 ;
const char * s ;
if ( ! r_editlights . ival )
return ;
if ( r_editlights_selected > = RTL_FIRST & & r_editlights_selected < rtlights_max )
{
dlight_t * dl = & cl_dlights [ r_editlights_selected ] ;
s = va ( " Origin : %.0f %.0f %.0f \n "
" Angles : %.0f %.0f %.0f \n "
" Colour : %.2f %.2f %.2f \n "
" Radius : %.0f \n "
" Corona : %.0f \n "
" Style : %i \n "
" Style String : %s \n "
" Shadows : %s \n "
" Cubemap : \" %s \" \n "
" CoronaSize : %.2f \n "
" Ambient : %.2f \n "
" Diffuse : %.2f \n "
" Specular : %.2f \n "
" NormalMode : %s \n "
" RealTimeMode : %s \n "
2021-08-24 06:06:05 +00:00
" FadeDist : %.0f-%.0f \n "
2018-11-19 06:37:25 +00:00
" Spin : %.0f %.0f %.0f \n "
" Cone : %.0f \n "
2019-04-01 10:16:36 +00:00
" Nearclip : %.0f \n "
2018-11-19 06:37:25 +00:00
//"NoStencil : %s\n"
//"Crepuscular : %s\n"
//"Ortho : %s\n"
, dl - > origin [ 0 ] , dl - > origin [ 1 ] , dl - > origin [ 2 ]
, dl - > angles [ 0 ] , dl - > angles [ 1 ] , dl - > angles [ 2 ]
, dl - > color [ 0 ] , dl - > color [ 1 ] , dl - > color [ 2 ]
2019-09-10 15:40:04 +00:00
, dl - > radius , dl - > corona , dl - > style , dl - > customstyle ? dl - > customstyle : " --- "
2018-11-19 06:37:25 +00:00
, ( ( dl - > flags & LFLAG_NOSHADOWS ) ? " no " : " yes " ) , dl - > cubemapname , dl - > coronascale
, dl - > lightcolourscales [ 0 ] , dl - > lightcolourscales [ 1 ] , dl - > lightcolourscales [ 2 ]
, ( ( dl - > flags & LFLAG_NORMALMODE ) ? " yes " : " no " ) , ( ( dl - > flags & LFLAG_REALTIMEMODE ) ? " yes " : " no " )
2021-08-24 06:06:05 +00:00
, dl - > fade [ 0 ] , dl - > fade [ 1 ]
2019-04-01 10:16:36 +00:00
, dl - > rotation [ 0 ] , dl - > rotation [ 1 ] , dl - > rotation [ 2 ] , dl - > fov , dl - > nearclip
2018-11-19 06:37:25 +00:00
//,((dl->flags&LFLAG_SHADOWMAP)?"no":"yes"),((dl->flags&LFLAG_CREPUSCULAR)?"yes":"no"),((dl->flags&LFLAG_ORTHO)?"yes":"no")
) ;
}
else
s = " No light selected " ;
R2D_ImageColours ( 0 , 0 , 0 , .35 ) ;
R2D_FillBlock ( x - 4 , y , 320 + 4 , 16 * 8 + 4 ) ;
R2D_ImageColours ( 1 , 1 , 1 , 1 ) ;
2021-08-24 06:06:05 +00:00
R_DrawTextField ( x , y , 320 , 19 * 8 , s , CON_WHITEMASK , CPRINT_LALIGN | CPRINT_TALIGN | CPRINT_NOWRAP , font_default , fontscale ) ;
2018-11-19 06:37:25 +00:00
}
void R_EditLights_DrawLights ( void )
{
const float SPRITE_SIZE = 8 ;
int i ;
dlight_t * l ;
enum
{
// ELS_CURSOR,
ELS_SELECTED ,
ELS_LIGHT ,
ELS_NOSHADOW ,
ELS_MAX
} ;
char * lightshaderinfo [ ] =
{
/* "gfx/editlights/cursor",
" .59..95. "
" 59....95 "
" 9.9..9.9 "
" ...99... "
" ...99... "
" 9.9..9.9 "
" 59....95 "
" .59..95. " ,
*/
" gfx/editlights/selected " ,
" 999..999 "
" 99....99 "
" 9......9 "
" ........ "
" ........ "
" 9......9 "
" 99....99 "
" 999..999 " ,
" gfx/editlights/light " ,
" ..1221.. "
" .245542. "
" 14677641 "
" 25799752 "
" 25799752 "
" 14677641 "
" .245542. "
" ..1221.. " ,
" gfx/editlights/noshadow " ,
" ..1221.. "
" .245542. "
" 14644641 "
" 274..472 " //mmm, donuts.
" 274..472 "
" 14644641 "
" .247742. "
" ..1221.. " ,
} ;
shader_t * shaders [ ELS_MAX ] , * s ;
unsigned int asciipalette [ 256 ] ;
asciipalette [ ' . ' ] = 0 ;
for ( i = 0 ; i < 10 ; i + + )
asciipalette [ ' 0 ' + i ] = 0xff000000 | ( ( int ) ( 255 / 9.0 * i ) * 0x010101 ) ;
if ( ! r_editlights . ival )
return ;
for ( i = 0 ; i < ELS_MAX ; i + + )
{
shaders [ i ] = R_RegisterShader ( lightshaderinfo [ i * 2 + 0 ] , SUF_NONE , va (
" { \n "
" program defaultadditivesprite \n "
" { \n "
" map $diffuse \n "
" blendfunc gl_one gl_one \n "
" rgbgen vertex \n "
" alphagen vertex \n "
" %s "
" } \n "
" } \n "
, ( i = = ELS_SELECTED ) ? " nodepth \n " : " " )
) ;
if ( ! shaders [ i ] - > defaulttextures - > base )
shaders [ i ] - > defaulttextures - > base = Image_GetTexture ( shaders [ i ] - > name , NULL , IF_LINEAR | IF_NOMIPMAP | IF_NOPICMIP | IF_CLAMP , lightshaderinfo [ i * 2 + 1 ] , asciipalette , 8 , 8 , TF_8PAL32 ) ;
}
if ( ! r_editlights_locked )
{
vec3_t targ , norm ;
int ent ;
int best = - 1 ;
float bestscore = 0 , score ;
VectorMA ( r_refdef . vieworg , r_editlights_cursordistance . value , vpn , targ ) ; //try to aim about 1024qu infront of the camera
CL_TraceLine ( r_refdef . vieworg , targ , r_editlights_cursor , norm , & ent ) ; //figure out where the cursor ends up
VectorMA ( r_editlights_cursor , r_editlights_cursorpushoff . value , norm , r_editlights_cursor ) ; //push off from the surface by 4qu.
VectorMA ( r_editlights_cursor , - r_editlights_cursorpushback . value , vpn , r_editlights_cursor ) ; //move it back towards the camera, for no apparent reason
if ( r_editlights_cursorgrid . value )
{ //snap to a grid, if set
for ( i = 0 ; i < 3 ; i + + )
r_editlights_cursor [ i ] = floor ( r_editlights_cursor [ i ] / r_editlights_cursorgrid . value + 0.5 ) * r_editlights_cursorgrid . value ;
}
// CLQ1_AddSpriteQuad(shaders[ELS_CURSOR], r_editlights_cursor, SPRITE_SIZE);
for ( i = RTL_FIRST ; i < rtlights_max ; i + + )
{
l = & cl_dlights [ i ] ;
if ( ! l - > radius ) //dead light is dead.
continue ;
VectorSubtract ( l - > origin , r_refdef . vieworg , targ ) ;
score = DotProduct ( vpn , targ ) / sqrt ( DotProduct ( targ , targ ) ) ;
if ( score > = .95 ) //there's a threshhold required for a light to be selectable.
{
//trace from the light to the view (so startsolid doesn't cause so many problems)
if ( score > bestscore & & CL_TraceLine ( l - > origin , r_refdef . vieworg , r_editlights_cursor , norm , & ent ) = = 1.0 )
{
bestscore = score ;
best = i ;
}
}
}
r_editlights_selected = best ;
}
for ( i = RTL_FIRST ; i < rtlights_max ; i + + )
{
l = & cl_dlights [ i ] ;
if ( ! l - > radius ) //dead light is dead.
continue ;
//we should probably show spotlights with a special icon or something
//dp has alternate icons for cubemaps.
if ( l - > flags & LFLAG_NOSHADOWS )
s = shaders [ ELS_NOSHADOW ] ;
else
s = shaders [ ELS_LIGHT ] ;
CLQ1_AddSpriteQuad ( s , l - > origin , SPRITE_SIZE ) ;
}
if ( r_editlights_selected > = RTL_FIRST & & r_editlights_selected < rtlights_max )
{
l = & cl_dlights [ r_editlights_selected ] ;
CLQ1_AddSpriteQuad ( shaders [ ELS_SELECTED ] , l - > origin , SPRITE_SIZE ) ;
}
}
static void R_EditLights_Edit_f ( void )
{
int i = r_editlights_selected ;
const char * cmd = Cmd_Argv ( 1 ) ;
const char * x = Cmd_Argv ( 2 ) ;
const char * y = Cmd_Argv ( 3 ) ;
const char * z = Cmd_Argv ( 4 ) ;
int argc = Cmd_Argc ( ) - 2 ;
dlight_t * dl ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
if ( i < RTL_FIRST | | i > = rtlights_max )
{
Con_Printf ( " No light selected \n " ) ;
return ;
}
dl = & cl_dlights [ i ] ;
if ( ! * cmd )
{
Con_Print ( " Selected light's properties: \n " ) ;
Con_Printf ( " Origin : ^[%f %f %f \\ type \\ r_editlights_edit origin %g %g %g^] \n " , dl - > origin [ 0 ] , dl - > origin [ 1 ] , dl - > origin [ 2 ] , dl - > origin [ 0 ] , dl - > origin [ 1 ] , dl - > origin [ 2 ] ) ;
Con_Printf ( " Angles : ^[%f %f %f \\ type \\ r_editlights_edit angles %g %g %g^] \n " , dl - > angles [ 0 ] , dl - > angles [ 1 ] , dl - > angles [ 2 ] , dl - > angles [ 0 ] , dl - > angles [ 1 ] , dl - > angles [ 2 ] ) ;
Con_Printf ( " Colour : ^[%f %f %f \\ type \\ r_editlights_edit avel %g %g %g^] \n " , dl - > color [ 0 ] , dl - > color [ 1 ] , dl - > color [ 2 ] , dl - > color [ 0 ] , dl - > color [ 1 ] , dl - > color [ 2 ] ) ;
Con_Printf ( " Radius : ^[%f \\ type \\ r_editlights_edit radius %g^] \n " , dl - > radius , dl - > radius ) ;
Con_Printf ( " Corona : ^[%f \\ type \\ r_editlights_edit corona %g^] \n " , dl - > corona , dl - > corona ) ;
2019-09-10 15:40:04 +00:00
Con_Printf ( " Style : ^[%i \\ type \\ r_editlights_edit style %i^] \n " , dl - > style , dl - > style ) ;
2018-11-19 06:37:25 +00:00
Con_Printf ( " Style String : ^[%s \\ type \\ r_editlights_edit stylestring %s^] \n " , dl - > customstyle ? dl - > customstyle : " --- " , dl - > customstyle ? dl - > customstyle : " " ) ;
Con_Printf ( " Shadows : ^[%s \\ type \\ r_editlights_edit shadows %s^] \n " , ( ( dl - > flags & LFLAG_NOSHADOWS ) ? " no " : " yes " ) , ( ( dl - > flags & LFLAG_NOSHADOWS ) ? " no " : " yes " ) ) ;
Con_Printf ( " Cubemap : ^[ \" %s \" \\ type \\ r_editlights_edit cubemap \" %s \" ^] \n " , dl - > cubemapname , dl - > cubemapname ) ;
Con_Printf ( " CoronaSize : ^[%f \\ type \\ r_editlights_edit coronasize %g^] \n " , dl - > coronascale , dl - > coronascale ) ;
Con_Printf ( " Ambient : ^[%f \\ type \\ r_editlights_edit ambient %g^] \n " , dl - > lightcolourscales [ 0 ] , dl - > lightcolourscales [ 0 ] ) ;
Con_Printf ( " Diffuse : ^[%f \\ type \\ r_editlights_edit diffuse %g^] \n " , dl - > lightcolourscales [ 1 ] , dl - > lightcolourscales [ 1 ] ) ;
Con_Printf ( " Specular : ^[%f \\ type \\ r_editlights_edit specular %g^] \n " , dl - > lightcolourscales [ 2 ] , dl - > lightcolourscales [ 2 ] ) ;
Con_Printf ( " NormalMode : ^[%s \\ type \\ r_editlights_edit normalmode %s^] \n " , ( ( dl - > flags & LFLAG_NORMALMODE ) ? " yes " : " no " ) , ( ( dl - > flags & LFLAG_NORMALMODE ) ? " yes " : " no " ) ) ;
Con_Printf ( " RealTimeMode : ^[%s \\ type \\ r_editlights_edit realtimemode %s^] \n " , ( ( dl - > flags & LFLAG_REALTIMEMODE ) ? " yes " : " no " ) , ( ( dl - > flags & LFLAG_REALTIMEMODE ) ? " yes " : " no " ) ) ;
Con_Printf ( " Spin : ^[%f %f %f \\ type \\ r_editlights_edit avel %g %g %g^] \n " , dl - > rotation [ 0 ] , dl - > rotation [ 1 ] , dl - > rotation [ 2 ] , dl - > origin [ 0 ] , dl - > origin [ 1 ] , dl - > origin [ 2 ] ) ;
Con_Printf ( " Cone : ^[%f \\ type \\ r_editlights_edit outercone %g^] \n " , dl - > fov , dl - > fov ) ;
2019-04-01 10:16:36 +00:00
Con_Printf ( " NearClip : ^[%f \\ type \\ r_editlights_edit nearclip %g^] \n " , dl - > nearclip , dl - > nearclip ) ;
2018-11-19 06:37:25 +00:00
// Con_Printf("NoStencil : ^[%s\\type\\r_editlights_edit nostencil %s^]\n", ((dl->flags&LFLAG_SHADOWMAP)?"no":"yes"), ((dl->flags&LFLAG_SHADOWMAP)?"no":"yes"));
// Con_Printf("Crepuscular : ^[%s\\type\\r_editlights_edit crepuscular %s^]\n", ((dl->flags&LFLAG_CREPUSCULAR)?"yes":"no"), ((dl->flags&LFLAG_CREPUSCULAR)?"yes":"no"));
// Con_Printf("Ortho : ^[%s\\type\\r_editlights_edit ortho %s^]\n", ((dl->flags&LFLAG_ORTHO)?"yes":"no"), ((dl->flags&LFLAG_ORTHO)?"yes":"no"));
return ;
}
switch ( R_EditLight ( dl , cmd , argc , x , y , z ) )
{
case - 1 :
Con_Printf ( " Not enough args for %s \n " , cmd ) ;
return ;
case - 2 :
Con_Printf ( " Argument not known: %s \n " , cmd ) ;
return ;
}
}
static void R_EditLights_Remove_f ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
if ( i < RTL_FIRST | | i > = rtlights_max )
{
Con_Printf ( " No light selected \n " ) ;
return ;
}
dl = & cl_dlights [ i ] ;
dl - > radius = 0 ;
r_editlights_selected = - 1 ;
}
static void R_EditLights_EditAll_f ( void )
{
int i = 0 ;
const char * cmd = Cmd_Argv ( 1 ) ;
const char * x = Cmd_Argv ( 2 ) ;
const char * y = Cmd_Argv ( 3 ) ;
const char * z = Cmd_Argv ( 4 ) ;
int argc = Cmd_Argc ( ) - 2 ;
dlight_t * dl ;
if ( ! r_editlights . ival )
{
Con_Printf ( " No light selected \n " ) ;
return ;
}
for ( i = RTL_FIRST ; i < rtlights_max ; i + + )
{
dl = & cl_dlights [ i ] ;
if ( dl - > radius < = 0 )
continue ; //don't edit dead lights back to life
switch ( R_EditLight ( dl , cmd , argc , x , y , z ) )
{
case - 1 :
Con_Printf ( " Not enough args for %s \n " , cmd ) ;
return ;
case - 2 :
Con_Printf ( " Argument not known: %s \n " , cmd ) ;
return ;
}
}
}
static void R_EditLights_Spawn_f ( void )
{
dlight_t * dl ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
dl = CL_AllocSlight ( ) ;
r_editlights_selected = dl - cl_dlights ;
VectorCopy ( r_editlights_cursor , dl - > origin ) ;
dl - > radius = 200 ;
2019-09-10 15:40:04 +00:00
dl - > style = 0 ; //styled, but mostly static (we could use -1, but mneh).
2018-11-19 06:37:25 +00:00
dl - > lightcolourscales [ 0 ] = 0 ;
dl - > lightcolourscales [ 1 ] = 1 ;
dl - > lightcolourscales [ 2 ] = 1 ;
}
static void R_EditLights_Clone_f ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
dlight_t * src ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
if ( i < RTL_FIRST | | i > = rtlights_max )
{
Con_Printf ( " No light selected \n " ) ;
return ;
}
src = & cl_dlights [ i ] ;
dl = CL_AllocSlight ( ) ;
r_editlights_selected = dl - cl_dlights ;
CL_CloneDlight ( dl , src ) ;
VectorCopy ( r_editlights_cursor , dl - > origin ) ;
}
static void R_EditLights_ToggleShadow_f ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
if ( i < RTL_FIRST | | i > = rtlights_max )
{
Con_Printf ( " No light selected \n " ) ;
return ;
}
dl = & cl_dlights [ i ] ;
dl - > flags ^ = LFLAG_NOSHADOWS ;
}
static void R_EditLights_ToggleCorona_f ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
if ( i < RTL_FIRST | | i > = rtlights_max )
{
Con_Printf ( " No light selected \n " ) ;
return ;
}
dl = & cl_dlights [ i ] ;
dl - > corona = ! dl - > corona ;
}
static void R_EditLights_CopyInfo_f ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
if ( i < RTL_FIRST | | i > = rtlights_max )
return ;
dl = & cl_dlights [ i ] ;
CL_CloneDlight ( & r_editlights_copybuffer , dl ) ;
}
static void R_EditLights_PasteInfo_f ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
vec3_t org ;
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
if ( i < RTL_FIRST | | i > = rtlights_max )
{
Con_Printf ( " No light selected \n " ) ;
return ;
}
dl = & cl_dlights [ i ] ;
VectorCopy ( dl - > origin , org ) ;
CL_CloneDlight ( dl , & r_editlights_copybuffer ) ;
VectorCopy ( org , dl - > origin ) ; //undo the origin's copy.
//just in case its from a different map...
if ( * dl - > cubemapname )
2019-10-18 08:37:38 +00:00
dl - > cubetexture = R_LoadReplacementTexture ( dl - > cubemapname , " " , IF_TEXTYPE_CUBE , NULL , 0 , 0 , TF_INVALID ) ;
2018-11-19 06:37:25 +00:00
else
dl - > cubetexture = r_nulltex ;
}
static void R_EditLights_Lock_f ( void )
{
if ( ! r_editlights . ival )
{
Con_Printf ( " Toggle r_editlights first \n " ) ;
return ;
}
2014-10-05 20:04:11 +00:00
2018-11-19 06:37:25 +00:00
if ( ( r_editlights_selected < RTL_FIRST | | r_editlights_selected > = rtlights_max ) & & ! r_editlights_locked )
2014-10-05 20:04:11 +00:00
{
2018-11-19 06:37:25 +00:00
Con_Printf ( " No light selected \n " ) ;
return ;
2014-10-05 20:04:11 +00:00
}
2018-11-19 06:37:25 +00:00
r_editlights_locked = ! r_editlights_locked ;
}
static char macro_buf [ 256 ] = " " ;
static char * r_editlights_current_origin ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g %g %g " , dl - > origin [ 0 ] , dl - > origin [ 1 ] , dl - > origin [ 2 ] ) ;
return macro_buf ;
}
static char * r_editlights_current_angles ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g %g %g " , dl - > angles [ 0 ] , dl - > angles [ 1 ] , dl - > angles [ 2 ] ) ;
return macro_buf ;
}
static char * r_editlights_current_color ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g %g %g " , dl - > color [ 0 ] , dl - > color [ 1 ] , dl - > color [ 2 ] ) ;
return macro_buf ;
}
static char * r_editlights_current_radius ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g " , dl - > radius ) ;
return macro_buf ;
}
static char * r_editlights_current_corona ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g " , dl - > corona ) ;
return macro_buf ;
}
static char * r_editlights_current_coronasize ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g " , dl - > coronascale ) ;
return macro_buf ;
}
static char * r_editlights_current_style ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
2019-09-10 15:40:04 +00:00
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %i " , dl - > style ) ;
2018-11-19 06:37:25 +00:00
return macro_buf ;
}
static char * r_editlights_current_shadows ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
if ( dl - > flags & LFLAG_NOSHADOWS )
return " 0 " ;
return " 1 " ;
}
static char * r_editlights_current_cubemap ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " \" %s \" " , dl - > cubemapname ) ;
return macro_buf ;
}
static char * r_editlights_current_ambient ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g " , dl - > lightcolourscales [ 0 ] ) ;
return macro_buf ;
}
static char * r_editlights_current_diffuse ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g " , dl - > lightcolourscales [ 1 ] ) ;
return macro_buf ;
}
static char * r_editlights_current_specular ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
Q_snprintfz ( macro_buf , sizeof ( macro_buf ) , " %g " , dl - > lightcolourscales [ 2 ] ) ;
return macro_buf ;
}
static char * r_editlights_current_normalmode ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
if ( dl - > flags & LFLAG_NORMALMODE )
return " 1 " ;
return " 0 " ;
}
static char * r_editlights_current_realtimemode ( void )
{
int i = r_editlights_selected ;
dlight_t * dl ;
if ( i < RTL_FIRST | | i > = rtlights_max )
return " " ;
dl = & cl_dlights [ i ] ;
if ( dl - > flags & LFLAG_REALTIMEMODE )
return " 1 " ;
return " 0 " ;
}
void R_EditLights_RegisterCommands ( void )
{
Cmd_AddCommandD ( " r_editlights_reload " , R_ReloadRTLights_f , " Reload static rtlights. Argument can be rtlights|statics|bsp|none to override the source. " ) ;
Cmd_AddCommandD ( " r_editlights_save " , R_SaveRTLights_f , " Saves rtlights to maps/FOO.rtlights " ) ;
Cvar_Register ( & r_editlights_import_radius , " Realtime Light editing/importing " ) ;
Cvar_Register ( & r_editlights_import_ambient , " Realtime Light editing/importing " ) ;
Cvar_Register ( & r_editlights_import_diffuse , " Realtime Light editing/importing " ) ;
Cvar_Register ( & r_editlights_import_specular , " Realtime Light editing/importing " ) ;
2020-05-14 15:50:26 +00:00
Cvar_Register ( & r_shadow_realtime_world_importlightentitiesfrommap , " Realtime Light editing/importing " ) ;
2018-11-19 06:37:25 +00:00
Cvar_Register ( & r_editlights , " Realtime Light editing/importing " ) ;
Cvar_Register ( & r_editlights_cursordistance , " Realtime Light editing/importing " ) ;
Cvar_Register ( & r_editlights_cursorpushoff , " Realtime Light editing/importing " ) ;
Cvar_Register ( & r_editlights_cursorpushback , " Realtime Light editing/importing " ) ;
Cvar_Register ( & r_editlights_cursorgrid , " Realtime Light editing/importing " ) ;
//the rest is optional stuff that should normally be handled via csqc instead, but hurrah for dp compat...
Cmd_AddCommandD ( " r_editlights_spawn " , R_EditLights_Spawn_f , " Spawn a new light with default properties " ) ;
Cmd_AddCommandD ( " r_editlights_clone " , R_EditLights_Clone_f , " Duplicate the current light (with a new origin) " ) ;
Cmd_AddCommandD ( " r_editlights_remove " , R_EditLights_Remove_f , " Removes the current light. " ) ;
Cmd_AddCommandD ( " r_editlights_edit " , R_EditLights_Edit_f , " Changes named properties on the current light. " ) ;
Cmd_AddCommandD ( " r_editlights_editall " , R_EditLights_EditAll_f , " Like r_editlights_edit, but affects all lights instead of just the selected one. " ) ;
Cmd_AddCommandD ( " r_editlights_toggleshadow " , R_EditLights_ToggleShadow_f , " Toggles the shadow flag on the current light. " ) ;
Cmd_AddCommandD ( " r_editlights_togglecorona " , R_EditLights_ToggleCorona_f , " Toggles the current light's corona field. " ) ;
Cmd_AddCommandD ( " r_editlights_copyinfo " , R_EditLights_CopyInfo_f , " store a copy of all properties (except origin) of the selected light " ) ;
Cmd_AddCommandD ( " r_editlights_pasteinfo " , R_EditLights_PasteInfo_f , " apply the stored properties onto the selected light (making it exactly identical except for origin) " ) ;
Cmd_AddCommandD ( " r_editlights_lock " , R_EditLights_Lock_f , " Blocks changing the current light according the crosshair. " ) ;
//DP has these as cvars. mneh.
Cmd_AddMacroD ( " r_editlights_current_origin " , r_editlights_current_origin , false , " origin of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_angles " , r_editlights_current_angles , false , " angles of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_color " , r_editlights_current_color , false , " color of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_radius " , r_editlights_current_radius , false , " radius of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_corona " , r_editlights_current_corona , false , " corona intensity of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_coronasize " , r_editlights_current_coronasize , false , " corona size of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_style " , r_editlights_current_style , false , " style of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_shadows " , r_editlights_current_shadows , false , " shadows flag of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_cubemap " , r_editlights_current_cubemap , false , " cubemap of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_ambient " , r_editlights_current_ambient , false , " ambient intensity of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_diffuse " , r_editlights_current_diffuse , false , " diffuse intensity of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_specular " , r_editlights_current_specular , false , " specular intensity of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_normalmode " , r_editlights_current_normalmode , false , " normalmode flag of selected light " ) ;
Cmd_AddMacroD ( " r_editlights_current_realtimemode " , r_editlights_current_realtimemode , false , " realtimemode flag of selected light " ) ;
2012-01-01 02:26:42 +00:00
}
# endif
2004-08-22 22:29:09 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
LIGHT SAMPLING
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
mplane_t * lightplane ;
vec3_t lightspot ;
2019-07-02 04:12:20 +00:00
static void GLQ3_AddLatLong ( const qbyte latlong [ 2 ] , vec3_t dir , float mag )
2015-06-28 00:42:00 +00:00
{
float lat = ( float ) latlong [ 0 ] * ( 2 * M_PI ) * ( 1.0 / 255.0 ) ;
float lng = ( float ) latlong [ 1 ] * ( 2 * M_PI ) * ( 1.0 / 255.0 ) ;
dir [ 0 ] + = mag * cos ( lng ) * sin ( lat ) ;
dir [ 1 ] + = mag * sin ( lng ) * sin ( lat ) ;
dir [ 2 ] + = mag * cos ( lat ) ;
}
2019-07-02 04:12:20 +00:00
void GLQ3_LightGrid ( model_t * mod , const vec3_t point , vec3_t res_diffuse , vec3_t res_ambient , vec3_t res_dir )
2004-08-22 22:29:09 +00:00
{
2021-07-06 16:32:59 +00:00
q3lightgridinfo_t * lg = ( q3lightgridinfo_t * ) mod - > lightgrid ;
2005-05-26 12:55:34 +00:00
int index [ 8 ] ;
2004-08-22 22:29:09 +00:00
int vi [ 3 ] ;
int i , j ;
2015-06-28 00:42:00 +00:00
float t [ 8 ] ;
2004-08-22 22:29:09 +00:00
vec3_t vf , vf2 ;
2015-06-28 00:42:00 +00:00
vec3_t ambient , diffuse , direction ;
2004-08-22 22:29:09 +00:00
2015-06-28 00:42:00 +00:00
if ( ! lg | | ( ! lg - > lightgrid & & ! lg - > rbspelements ) | | lg - > numlightgridelems < 1 )
2004-08-22 22:29:09 +00:00
{
2004-11-17 18:13:33 +00:00
if ( res_ambient )
{
res_ambient [ 0 ] = 64 ;
res_ambient [ 1 ] = 64 ;
res_ambient [ 2 ] = 64 ;
}
2004-11-13 17:31:04 +00:00
2004-11-17 18:13:33 +00:00
if ( res_diffuse )
{
res_diffuse [ 0 ] = 192 ;
res_diffuse [ 1 ] = 192 ;
res_diffuse [ 2 ] = 192 ;
}
2015-06-28 00:42:00 +00:00
if ( res_dir )
{
res_dir [ 0 ] = 1 ;
res_dir [ 1 ] = 1 ;
res_dir [ 2 ] = 0.1 ;
}
2004-08-22 22:29:09 +00:00
return ;
}
//If in doubt, steal someone else's code...
//Thanks QFusion.
for ( i = 0 ; i < 3 ; i + + )
{
vf [ i ] = ( point [ i ] - lg - > gridMins [ i ] ) / lg - > gridSize [ i ] ;
2005-05-26 12:55:34 +00:00
vi [ i ] = ( int ) ( vf [ i ] ) ;
2004-08-22 22:29:09 +00:00
vf [ i ] = vf [ i ] - floor ( vf [ i ] ) ;
vf2 [ i ] = 1.0f - vf [ i ] ;
}
2005-05-26 12:55:34 +00:00
for ( i = 0 ; i < 8 ; i + + )
2004-08-22 22:29:09 +00:00
{
2015-06-28 00:42:00 +00:00
//bound it properly
index [ i ] = bound ( 0 , vi [ 0 ] + ( ( i & 1 ) ? 1 : 0 ) , lg - > gridBounds [ 0 ] - 1 ) * 1 +
bound ( 0 , vi [ 1 ] + ( ( i & 2 ) ? 1 : 0 ) , lg - > gridBounds [ 1 ] - 1 ) * lg - > gridBounds [ 0 ] +
bound ( 0 , vi [ 2 ] + ( ( i & 4 ) ? 1 : 0 ) , lg - > gridBounds [ 2 ] - 1 ) * lg - > gridBounds [ 3 ] ;
t [ i ] = ( ( i & 1 ) ? vf [ 0 ] : vf2 [ 0 ] ) *
( ( i & 2 ) ? vf [ 1 ] : vf2 [ 1 ] ) *
( ( i & 4 ) ? vf [ 2 ] : vf2 [ 2 ] ) ;
2004-08-22 22:29:09 +00:00
}
2015-06-28 00:42:00 +00:00
//rbsp has a separate grid->index lookup for compression.
if ( lg - > rbspindexes )
2004-08-22 22:29:09 +00:00
{
2015-06-28 00:42:00 +00:00
for ( i = 0 ; i < 8 ; i + + )
index [ i ] = lg - > rbspindexes [ index [ i ] ] ;
}
2004-08-22 22:29:09 +00:00
2015-06-28 00:42:00 +00:00
VectorClear ( ambient ) ;
VectorClear ( diffuse ) ;
VectorClear ( direction ) ;
if ( lg - > rbspelements )
{
for ( i = 0 ; i < 8 ; i + + )
{ //rbsp has up to 4 styles per grid element, which needs to be scaled by that style's current value
float tot = 0 ;
for ( j = 0 ; j < countof ( lg - > rbspelements [ index [ i ] ] . styles ) ; j + + )
{
qbyte st = lg - > rbspelements [ index [ i ] ] . styles [ j ] ;
if ( st ! = 255 )
{
float mag = d_lightstylevalue [ st ] * 1.0 / 255 * t [ i ] ;
//FIXME: cl_lightstyle[st].colours[rgb]
VectorMA ( ambient , mag , lg - > rbspelements [ index [ i ] ] . ambient [ j ] , ambient ) ;
VectorMA ( diffuse , mag , lg - > rbspelements [ index [ i ] ] . diffuse [ j ] , diffuse ) ;
tot + = mag ;
}
}
GLQ3_AddLatLong ( lg - > rbspelements [ index [ i ] ] . direction , direction , tot ) ;
2004-08-22 22:29:09 +00:00
}
}
2015-06-28 00:42:00 +00:00
else
2004-08-22 22:29:09 +00:00
{
2015-06-28 00:42:00 +00:00
for ( i = 0 ; i < 8 ; i + + )
2004-08-22 22:29:09 +00:00
{
2015-06-28 00:42:00 +00:00
VectorMA ( ambient , t [ i ] , lg - > lightgrid [ index [ i ] ] . ambient , ambient ) ;
VectorMA ( diffuse , t [ i ] , lg - > lightgrid [ index [ i ] ] . diffuse , diffuse ) ;
GLQ3_AddLatLong ( lg - > lightgrid [ index [ i ] ] . direction , direction , t [ i ] ) ;
2004-08-22 22:29:09 +00:00
}
2015-06-28 00:42:00 +00:00
VectorScale ( ambient , d_lightstylevalue [ 0 ] / 255.0 , ambient ) ;
VectorScale ( diffuse , d_lightstylevalue [ 0 ] / 255.0 , diffuse ) ;
//FIXME: cl_lightstyle[0].colours[rgb]
2004-08-22 22:29:09 +00:00
}
2015-06-28 00:42:00 +00:00
//q3bsp has *4 overbrighting.
// VectorScale(ambient, 4, ambient);
// VectorScale(diffuse, 4, diffuse);
2011-10-27 16:16:29 +00:00
/*ambient is the min level*/
/*diffuse is the max level*/
2004-08-22 22:29:09 +00:00
VectorCopy ( ambient , res_ambient ) ;
if ( res_diffuse )
2011-10-27 16:16:29 +00:00
VectorAdd ( diffuse , ambient , res_diffuse ) ;
2004-08-22 22:29:09 +00:00
if ( res_dir )
2015-06-28 00:42:00 +00:00
VectorCopy ( direction , res_dir ) ;
2004-08-22 22:29:09 +00:00
}
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
static int GLRecursiveLightPoint ( mnode_t * node , vec3_t start , vec3_t end )
2004-08-22 22:29:09 +00:00
{
int r ;
float front , back , frac ;
int side ;
mplane_t * plane ;
vec3_t mid ;
msurface_t * surf ;
int s , t , ds , dt ;
int i ;
mtexinfo_t * tex ;
qbyte * lightmap ;
unsigned scale ;
int maps ;
if ( cl . worldmodel - > fromgame = = fg_quake2 )
{
if ( node - > contents ! = - 1 )
return - 1 ; // solid
}
else if ( node - > contents < 0 )
return - 1 ; // didn't hit anything
// calculate mid point
// FIXME: optimize for axial
plane = node - > plane ;
front = DotProduct ( start , plane - > normal ) - plane - > dist ;
back = DotProduct ( end , plane - > normal ) - plane - > dist ;
side = front < 0 ;
if ( ( back < 0 ) = = side )
return GLRecursiveLightPoint ( node - > children [ side ] , start , end ) ;
frac = front / ( front - back ) ;
mid [ 0 ] = start [ 0 ] + ( end [ 0 ] - start [ 0 ] ) * frac ;
mid [ 1 ] = start [ 1 ] + ( end [ 1 ] - start [ 1 ] ) * frac ;
mid [ 2 ] = start [ 2 ] + ( end [ 2 ] - start [ 2 ] ) * frac ;
// go down front side
r = GLRecursiveLightPoint ( node - > children [ side ] , start , mid ) ;
if ( r > = 0 )
return r ; // hit something
if ( ( back < 0 ) = = side )
return - 1 ; // didn't hit anuthing
// check for impact on this node
VectorCopy ( mid , lightspot ) ;
lightplane = plane ;
surf = cl . worldmodel - > surfaces + node - > firstsurface ;
for ( i = 0 ; i < node - > numsurfaces ; i + + , surf + + )
{
if ( surf - > flags & SURF_DRAWTILED )
continue ; // no lightmaps
tex = surf - > texinfo ;
s = DotProduct ( mid , tex - > vecs [ 0 ] ) + tex - > vecs [ 0 ] [ 3 ] ;
t = DotProduct ( mid , tex - > vecs [ 1 ] ) + tex - > vecs [ 1 ] [ 3 ] ; ;
2011-07-30 14:14:56 +00:00
if ( s < surf - > texturemins [ 0 ] | | t < surf - > texturemins [ 1 ] )
2004-08-22 22:29:09 +00:00
continue ;
ds = s - surf - > texturemins [ 0 ] ;
dt = t - surf - > texturemins [ 1 ] ;
if ( ds > surf - > extents [ 0 ] | | dt > surf - > extents [ 1 ] )
continue ;
if ( ! surf - > samples )
return 0 ;
2015-03-03 00:14:43 +00:00
ds > > = surf - > lmshift ;
dt > > = surf - > lmshift ;
2004-08-22 22:29:09 +00:00
lightmap = surf - > samples ;
r = 0 ;
if ( lightmap )
{
2018-03-04 14:41:16 +00:00
switch ( cl . worldmodel - > lightmaps . fmt )
2004-08-22 22:29:09 +00:00
{
2018-03-04 14:41:16 +00:00
case LM_E5BGR9 :
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) < < 2 ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2018-03-04 14:41:16 +00:00
{
unsigned int l = * ( unsigned int * ) lightmap ;
scale = d_lightstylevalue [ surf - > styles [ maps ] ] ;
scale * = pow ( 2 , ( int ) ( l > > 27 ) - 15 - 9 + 7 ) ;
2004-08-22 22:29:09 +00:00
2018-03-04 14:41:16 +00:00
r + = max3 ( ( ( l > > 0 ) & 0x1ff ) , ( ( l > > 9 ) & 0x1ff ) , ( ( l > > 18 ) & 0x1ff ) ) * scale ;
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) * ( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) < < 2 ;
}
break ;
case LM_RGB8 :
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) * 3 ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2004-08-22 22:29:09 +00:00
{
scale = d_lightstylevalue [ surf - > styles [ maps ] ] ;
2018-03-04 14:41:16 +00:00
r + = max3 ( lightmap [ 0 ] , lightmap [ 1 ] , lightmap [ 2 ] ) * scale ;
2015-03-03 00:14:43 +00:00
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) * ( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) * 3 ;
2004-08-22 22:29:09 +00:00
}
2018-03-04 14:41:16 +00:00
break ;
case LM_L8 :
2015-03-03 00:14:43 +00:00
lightmap + = dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2004-08-22 22:29:09 +00:00
{
scale = d_lightstylevalue [ surf - > styles [ maps ] ] ;
r + = * lightmap * scale ;
2015-03-03 00:14:43 +00:00
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) * ( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) ;
2004-08-22 22:29:09 +00:00
}
2018-03-04 14:41:16 +00:00
break ;
2004-08-22 22:29:09 +00:00
}
r > > = 8 ;
}
return r ;
}
// go down back side
return GLRecursiveLightPoint ( node - > children [ ! side ] , mid , end ) ;
}
2012-05-09 15:30:53 +00:00
int R_LightPoint ( vec3_t p )
2004-08-22 22:29:09 +00:00
{
vec3_t end ;
int r ;
if ( r_refdef . flags & 1 )
return 255 ;
2005-08-26 22:56:51 +00:00
2017-07-12 08:15:27 +00:00
if ( ! cl . worldmodel | | cl . worldmodel - > loadstate ! = MLS_LOADED | | ! cl . worldmodel - > lightdata )
2004-08-22 22:29:09 +00:00
return 255 ;
if ( cl . worldmodel - > fromgame = = fg_quake3 )
{
2006-09-17 00:59:22 +00:00
GLQ3_LightGrid ( cl . worldmodel , p , NULL , end , NULL ) ;
2004-08-22 22:29:09 +00:00
return ( end [ 0 ] + end [ 1 ] + end [ 2 ] ) / 3 ;
}
2005-08-26 22:56:51 +00:00
2004-08-22 22:29:09 +00:00
end [ 0 ] = p [ 0 ] ;
end [ 1 ] = p [ 1 ] ;
2022-01-08 09:59:54 +00:00
end [ 2 ] = p [ 2 ] - mod_lightpoint_distance . value ;
2005-08-26 22:56:51 +00:00
2014-05-10 13:42:13 +00:00
r = GLRecursiveLightPoint ( cl . worldmodel - > rootnode , p , end ) ;
2004-08-22 22:29:09 +00:00
if ( r = = - 1 )
r = 0 ;
return r ;
}
# ifdef PEXT_LIGHTSTYLECOL
2019-07-02 04:12:20 +00:00
static float * GLRecursiveLightPoint3C ( model_t * mod , mnode_t * node , const vec3_t start , const vec3_t end )
2004-08-22 22:29:09 +00:00
{
static float l [ 6 ] ;
float * r ;
float front , back , frac ;
int side ;
mplane_t * plane ;
vec3_t mid ;
msurface_t * surf ;
int s , t , ds , dt ;
int i ;
mtexinfo_t * tex ;
qbyte * lightmap , * deluxmap ;
2014-05-10 13:42:13 +00:00
float scale , overbright ;
2004-08-22 22:29:09 +00:00
int maps ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
if ( mod - > fromgame = = fg_quake2 )
2004-08-22 22:29:09 +00:00
{
if ( node - > contents ! = - 1 )
return NULL ; // solid
}
else if ( node - > contents < 0 )
return NULL ; // didn't hit anything
// calculate mid point
// FIXME: optimize for axial
plane = node - > plane ;
front = DotProduct ( start , plane - > normal ) - plane - > dist ;
back = DotProduct ( end , plane - > normal ) - plane - > dist ;
side = front < 0 ;
2017-01-13 00:39:50 +00:00
2004-08-22 22:29:09 +00:00
if ( ( back < 0 ) = = side )
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
return GLRecursiveLightPoint3C ( mod , node - > children [ side ] , start , end ) ;
2017-01-13 00:39:50 +00:00
2004-08-22 22:29:09 +00:00
frac = front / ( front - back ) ;
mid [ 0 ] = start [ 0 ] + ( end [ 0 ] - start [ 0 ] ) * frac ;
mid [ 1 ] = start [ 1 ] + ( end [ 1 ] - start [ 1 ] ) * frac ;
mid [ 2 ] = start [ 2 ] + ( end [ 2 ] - start [ 2 ] ) * frac ;
// go down front side
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
r = GLRecursiveLightPoint3C ( mod , node - > children [ side ] , start , mid ) ;
2004-08-22 22:29:09 +00:00
if ( r & & r [ 0 ] + r [ 1 ] + r [ 2 ] > = 0 )
return r ; // hit something
2017-01-13 00:39:50 +00:00
2004-08-22 22:29:09 +00:00
if ( ( back < 0 ) = = side )
return NULL ; // didn't hit anuthing
2017-01-13 00:39:50 +00:00
2004-08-22 22:29:09 +00:00
// check for impact on this node
VectorCopy ( mid , lightspot ) ;
lightplane = plane ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
surf = mod - > surfaces + node - > firstsurface ;
2004-08-22 22:29:09 +00:00
for ( i = 0 ; i < node - > numsurfaces ; i + + , surf + + )
{
if ( surf - > flags & SURF_DRAWTILED )
continue ; // no lightmaps
tex = surf - > texinfo ;
s = DotProduct ( mid , tex - > vecs [ 0 ] ) + tex - > vecs [ 0 ] [ 3 ] ;
t = DotProduct ( mid , tex - > vecs [ 1 ] ) + tex - > vecs [ 1 ] [ 3 ] ;
if ( s < surf - > texturemins [ 0 ] | |
t < surf - > texturemins [ 1 ] )
continue ;
2017-01-13 00:39:50 +00:00
2004-08-22 22:29:09 +00:00
ds = s - surf - > texturemins [ 0 ] ;
dt = t - surf - > texturemins [ 1 ] ;
if ( ds > surf - > extents [ 0 ] | | dt > surf - > extents [ 1 ] )
continue ;
if ( ! surf - > samples )
{
l [ 0 ] = 0 ; l [ 1 ] = 0 ; l [ 2 ] = 0 ;
l [ 3 ] = 0 ; l [ 4 ] = 1 ; l [ 5 ] = 1 ;
return l ;
}
2015-03-03 00:14:43 +00:00
ds > > = surf - > lmshift ;
dt > > = surf - > lmshift ;
2004-08-22 22:29:09 +00:00
lightmap = surf - > samples ;
l [ 0 ] = 0 ; l [ 1 ] = 0 ; l [ 2 ] = 0 ;
l [ 3 ] = 0 ; l [ 4 ] = 0 ; l [ 5 ] = 0 ;
if ( lightmap )
{
2014-05-10 13:42:13 +00:00
overbright = 1 / 255.0f ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
if ( mod - > deluxdata )
2004-08-22 22:29:09 +00:00
{
2018-03-04 14:41:16 +00:00
switch ( mod - > lightmaps . fmt )
2004-08-22 22:29:09 +00:00
{
2018-03-04 14:41:16 +00:00
case LM_E5BGR9 :
deluxmap = ( ( surf - > samples - mod - > lightdata ) > > 2 ) * 3 + mod - > deluxdata ;
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) < < 2 ;
deluxmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) < < 4 ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2018-03-04 14:41:16 +00:00
{
unsigned int lm = * ( unsigned int * ) lightmap ;
scale = d_lightstylevalue [ surf - > styles [ maps ] ] * overbright ;
scale * = pow ( 2 , ( int ) ( lm > > 27 ) - 15 - 9 + 8 ) ;
l [ 0 ] + = ( ( lm > > 0 ) & 0x1ff ) * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 0 ] ;
l [ 1 ] + = ( ( lm > > 9 ) & 0x1ff ) * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 1 ] ;
l [ 2 ] + = ( ( lm > > 18 ) & 0x1ff ) * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 2 ] ;
l [ 3 ] + = ( deluxmap [ 0 ] - 127 ) * scale ;
l [ 4 ] + = ( deluxmap [ 1 ] - 127 ) * scale ;
l [ 5 ] + = ( deluxmap [ 2 ] - 127 ) * scale ;
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) < < 2 ;
deluxmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) * 3 ;
}
break ;
case LM_RGB8 :
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
deluxmap = surf - > samples - mod - > lightdata + mod - > deluxdata ;
2004-08-22 22:29:09 +00:00
2015-03-03 00:14:43 +00:00
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) * 3 ;
deluxmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) * 3 ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2004-08-22 22:29:09 +00:00
{
2014-05-10 13:42:13 +00:00
scale = d_lightstylevalue [ surf - > styles [ maps ] ] * overbright ;
2004-08-22 22:29:09 +00:00
2014-06-25 03:53:11 +00:00
l [ 0 ] + = lightmap [ 0 ] * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 0 ] ;
l [ 1 ] + = lightmap [ 1 ] * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 1 ] ;
l [ 2 ] + = lightmap [ 2 ] * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 2 ] ;
2004-08-22 22:29:09 +00:00
l [ 3 ] + = ( deluxmap [ 0 ] - 127 ) * scale ;
l [ 4 ] + = ( deluxmap [ 1 ] - 127 ) * scale ;
l [ 5 ] + = ( deluxmap [ 2 ] - 127 ) * scale ;
2015-03-03 00:14:43 +00:00
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) * 3 ;
deluxmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) * 3 ;
2004-08-22 22:29:09 +00:00
}
2018-03-04 14:41:16 +00:00
break ;
case LM_L8 :
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
deluxmap = ( surf - > samples - mod - > lightdata ) * 3 + mod - > deluxdata ;
2004-08-22 22:29:09 +00:00
2015-03-03 00:14:43 +00:00
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) ;
deluxmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) * 3 ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2004-08-22 22:29:09 +00:00
{
2014-05-10 13:42:13 +00:00
scale = d_lightstylevalue [ surf - > styles [ maps ] ] * overbright ;
2004-08-22 22:29:09 +00:00
2014-06-25 03:53:11 +00:00
l [ 0 ] + = * lightmap * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 0 ] ;
l [ 1 ] + = * lightmap * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 1 ] ;
l [ 2 ] + = * lightmap * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 2 ] ;
2004-08-22 22:29:09 +00:00
l [ 3 ] + = deluxmap [ 0 ] * scale ;
l [ 4 ] + = deluxmap [ 1 ] * scale ;
l [ 5 ] + = deluxmap [ 2 ] * scale ;
2015-03-03 00:14:43 +00:00
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) ;
deluxmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) * 3 ;
2004-08-22 22:29:09 +00:00
}
2018-03-04 14:41:16 +00:00
break ;
2004-08-22 22:29:09 +00:00
}
}
else
{
2018-03-04 14:41:16 +00:00
switch ( mod - > lightmaps . fmt )
2004-08-22 22:29:09 +00:00
{
2018-03-04 14:41:16 +00:00
case LM_E5BGR9 :
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) < < 2 ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2018-03-04 14:41:16 +00:00
{
unsigned int lm = * ( unsigned int * ) lightmap ;
scale = d_lightstylevalue [ surf - > styles [ maps ] ] * overbright ;
scale * = pow ( 2 , ( int ) ( lm > > 27 ) - 15 - 9 + 8 ) ;
l [ 0 ] + = ( ( lm > > 0 ) & 0x1ff ) * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 0 ] ;
l [ 1 ] + = ( ( lm > > 9 ) & 0x1ff ) * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 1 ] ;
l [ 2 ] + = ( ( lm > > 18 ) & 0x1ff ) * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 2 ] ;
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) < < 2 ;
}
break ;
case LM_RGB8 :
2015-03-03 00:14:43 +00:00
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) * 3 ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2004-08-22 22:29:09 +00:00
{
2014-05-10 13:42:13 +00:00
scale = d_lightstylevalue [ surf - > styles [ maps ] ] * overbright ;
2004-08-22 22:29:09 +00:00
2014-06-25 03:53:11 +00:00
l [ 0 ] + = lightmap [ 0 ] * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 0 ] ;
l [ 1 ] + = lightmap [ 1 ] * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 1 ] ;
l [ 2 ] + = lightmap [ 2 ] * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 2 ] ;
2004-08-22 22:29:09 +00:00
2015-03-03 00:14:43 +00:00
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) * 3 ;
2004-08-22 22:29:09 +00:00
}
2018-03-04 14:41:16 +00:00
break ;
case LM_L8 :
2015-03-03 00:14:43 +00:00
lightmap + = ( dt * ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) + ds ) ;
2020-03-25 21:29:30 +00:00
for ( maps = 0 ; maps < MAXCPULIGHTMAPS & & surf - > styles [ maps ] ! = INVALID_LIGHTSTYLE ; maps + + )
2004-08-22 22:29:09 +00:00
{
2014-05-10 13:42:13 +00:00
scale = d_lightstylevalue [ surf - > styles [ maps ] ] * overbright ;
2004-08-22 22:29:09 +00:00
2014-06-25 03:53:11 +00:00
l [ 0 ] + = * lightmap * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 0 ] ;
l [ 1 ] + = * lightmap * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 1 ] ;
l [ 2 ] + = * lightmap * scale * cl_lightstyle [ surf - > styles [ maps ] ] . colours [ 2 ] ;
2004-08-22 22:29:09 +00:00
2015-03-03 00:14:43 +00:00
lightmap + = ( ( surf - > extents [ 0 ] > > surf - > lmshift ) + 1 ) *
( ( surf - > extents [ 1 ] > > surf - > lmshift ) + 1 ) ;
2004-08-22 22:29:09 +00:00
}
2018-03-04 14:41:16 +00:00
break ;
2004-08-22 22:29:09 +00:00
}
}
}
return l ;
}
// go down back side
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
return GLRecursiveLightPoint3C ( mod , node - > children [ ! side ] , mid , end ) ;
2004-08-22 22:29:09 +00:00
}
# endif
2019-07-02 04:12:20 +00:00
void GLQ1BSP_LightPointValues ( model_t * model , const vec3_t point , vec3_t res_diffuse , vec3_t res_ambient , vec3_t res_dir )
2004-08-22 22:29:09 +00:00
{
vec3_t end ;
float * r ;
2016-02-15 06:01:17 +00:00
# ifdef RTLIGHTS
2011-04-30 17:21:10 +00:00
extern cvar_t r_shadow_realtime_world , r_shadow_realtime_world_lightmaps ;
2016-02-15 06:01:17 +00:00
# endif
2004-08-22 22:29:09 +00:00
2020-07-15 23:50:30 +00:00
if ( ! model - > lightdata | | r_fullbright . ival | | model - > loadstate ! = MLS_LOADED )
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
{
2020-07-15 23:50:30 +00:00
if ( model - > loadstate ! = MLS_LOADED )
Sys_Error ( " GLQ1BSP_LightPointValues: model not loaded... \n " ) ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
res_diffuse [ 0 ] = 0 ;
res_diffuse [ 1 ] = 0 ;
res_diffuse [ 2 ] = 0 ;
res_ambient [ 0 ] = 255 ;
res_ambient [ 1 ] = 255 ;
res_ambient [ 2 ] = 255 ;
res_dir [ 0 ] = 1 ;
res_dir [ 1 ] = 1 ;
res_dir [ 2 ] = 0.1 ;
VectorNormalize ( res_dir ) ;
return ;
}
2004-08-22 22:29:09 +00:00
end [ 0 ] = point [ 0 ] ;
end [ 1 ] = point [ 1 ] ;
2022-01-08 09:59:54 +00:00
end [ 2 ] = point [ 2 ] - mod_lightpoint_distance . value ;
2004-08-22 22:29:09 +00:00
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
r = GLRecursiveLightPoint3C ( model , model - > rootnode , point , end ) ;
2004-08-22 22:29:09 +00:00
if ( r = = NULL )
{
res_diffuse [ 0 ] = 0 ;
res_diffuse [ 1 ] = 0 ;
res_diffuse [ 2 ] = 0 ;
res_ambient [ 0 ] = 0 ;
res_ambient [ 1 ] = 0 ;
res_ambient [ 2 ] = 0 ;
res_dir [ 0 ] = 0 ;
res_dir [ 1 ] = 1 ;
res_dir [ 2 ] = 1 ;
}
else
{
2018-03-04 14:41:16 +00:00
res_diffuse [ 0 ] = r [ 0 ] ;
res_diffuse [ 1 ] = r [ 1 ] ;
res_diffuse [ 2 ] = r [ 2 ] ;
2011-04-30 17:21:10 +00:00
/*bright on one side, dark on the other, but not too dark*/
2014-05-10 13:42:13 +00:00
res_ambient [ 0 ] = r [ 0 ] / 2 ;
res_ambient [ 1 ] = r [ 1 ] / 2 ;
res_ambient [ 2 ] = r [ 2 ] / 2 ;
2004-08-22 22:29:09 +00:00
res_dir [ 0 ] = r [ 3 ] ;
res_dir [ 1 ] = r [ 4 ] ;
res_dir [ 2 ] = - r [ 5 ] ;
if ( ! res_dir [ 0 ] & & ! res_dir [ 1 ] & & ! res_dir [ 2 ] )
2018-01-03 04:40:06 +00:00
res_dir [ 0 ] = res_dir [ 2 ] = 1 ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
VectorNormalize ( res_dir ) ;
2004-08-22 22:29:09 +00:00
}
2011-04-30 17:21:10 +00:00
2012-09-30 05:52:03 +00:00
# ifdef RTLIGHTS
2011-04-30 17:21:10 +00:00
if ( r_shadow_realtime_world . ival )
{
2014-03-30 08:55:06 +00:00
float lm = r_shadow_realtime_world_lightmaps . value ;
if ( lm < 0 ) lm = 0 ;
if ( lm > 1 ) lm = 1 ;
VectorScale ( res_diffuse , lm , res_diffuse ) ;
VectorScale ( res_ambient , lm , res_ambient ) ;
2011-04-30 17:21:10 +00:00
}
2012-09-30 05:52:03 +00:00
# endif
2004-08-22 22:29:09 +00:00
}
2004-12-15 19:53:30 +00:00
# endif