From 8cebaa695fbe11bc631e3e5fd070e22f151f4710 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 2 Mar 2004 00:22:31 +0000 Subject: [PATCH] dlights using light_lev now need the PFLAG_FULLDYNAMIC flag set to operate, otherwise they are ignored, this was necessary (lights that did not remove themselves were being treated as proper dlights), it is also now more tenebrae compatible (EF_FULLDYNAMIC translated to PFLAG_FULLDYNAMIC in GAME_TENEBRAE mode) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3947 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 11 ++++++++--- protocol.h | 5 +++++ r_shadow.c | 16 +++++++++++++--- sv_main.c | 24 +++++++++++++++++++++++- todo | 7 +++++-- 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/cl_main.c b/cl_main.c index 768397e1..5ccdc562 100644 --- a/cl_main.c +++ b/cl_main.c @@ -798,9 +798,12 @@ void CL_LinkNetworkEntity(entity_t *e) dlightradius = max(dlightradius, e->state_current.glowsize * 4); VectorMA(dlightcolor, (1.0f / 255.0f), (qbyte *)&palette_complete[e->state_current.glowcolor], dlightcolor); } - if (e->state_current.light[3]) + if (e->state_current.lightpflags & PFLAGS_FULLDYNAMIC) { - dlightradius = max(dlightradius, e->state_current.light[3]); + if (e->state_current.light[3]) + dlightradius = max(dlightradius, e->state_current.light[3]); + else + dlightradius = max(dlightradius, 350); if (VectorLength2(dlightcolor) == 0) (dlightcolor[0] += 1, dlightcolor[1] += 1, dlightcolor[2] += 1); else @@ -813,7 +816,7 @@ void CL_LinkNetworkEntity(entity_t *e) // hack to make glowing player light shine on their gun if ((e - cl_entities) == cl.viewentity/* && !chase_active.integer*/) dlightmatrix.m[2][3] += 30; - CL_AllocDlight(&e->render, &dlightmatrix, dlightradius, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0, e->state_current.skin >= 16 ? e->state_current.skin : 0, e->state_current.lightstyle, !(e->state_current.lightpflags & 1), 1); + CL_AllocDlight(&e->render, &dlightmatrix, dlightradius, dlightcolor[0], dlightcolor[1], dlightcolor[2], 0, 0, e->state_current.skin >= 16 ? e->state_current.skin : 0, e->state_current.lightstyle, !(e->state_current.lightpflags & PFLAGS_NOSHADOW), (e->state_current.lightpflags & PFLAGS_FULLDYNAMIC) ? ((e->state_current.lightpflags & PFLAGS_CORONA) != 0) : 1); } // trails need the previous frame if (e->state_previous.active && e->state_previous.modelindex == e->state_current.modelindex) @@ -839,6 +842,8 @@ void CL_LinkNetworkEntity(entity_t *e) V_CalcRefdef(); if (e->render.model && e->render.model->name[0] == '*' && e->render.model->TraceBox) cl_brushmodel_entities[cl_num_brushmodel_entities++] = &e->render; + if (gamemode == GAME_TENEBRAE && e->render.model && e->render.model->type == mod_sprite) + e->render.effects |= EF_ADDITIVE; // don't show entities with no modelindex (note: this still shows // entities which have a modelindex that resolved to a NULL model) if (e->render.model && !(e->render.effects & EF_NODRAW) && r_refdef.numentities < r_refdef.maxentities) diff --git a/protocol.h b/protocol.h index 717d9916..0d1f87d8 100644 --- a/protocol.h +++ b/protocol.h @@ -61,6 +61,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define EF_STEP 0x80000000 // internal client use only - present on MOVETYPE_STEP entities, not QC accessible (too many bits) +// flags for the pflags field of entities +#define PFLAGS_NOSHADOW 1 +#define PFLAGS_CORONA 2 +#define PFLAGS_FULLDYNAMIC 128 // must be set or the light fields are ignored + // if the high bit of the servercmd is set, the low bits are fast update flags: #define U_MOREBITS (1<<0) #define U_ORIGIN1 (1<<1) diff --git a/r_shadow.c b/r_shadow.c index a62dfaec..0083e426 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -2718,7 +2718,7 @@ void R_Shadow_LoadLightsFile(void) void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void) { - int entnum, style, islight, skin, pflags; + int entnum, style, islight, skin, pflags, effects; char key[256], value[1024]; float origin[3], angles[3], radius, color[3], light, fadescale, lightscale, originhack[3], overridecolor[3]; const char *data; @@ -2857,6 +2857,8 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void) skin = (int)atof(value); else if (!strcmp("pflags", key)) pflags = (int)atof(value); + else if (!strcmp("effects", key)) + effects = (int)atof(value); } if (light <= 0 && islight) light = 300; @@ -2864,14 +2866,22 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void) lightscale = 1; if (fadescale <= 0) fadescale = 1; + if (gamemode == GAME_TENEBRAE) + { + if (effects & EF_NODRAW) + { + pflags |= PFLAGS_FULLDYNAMIC; + effects &= ~EF_NODRAW; + } + } radius = min(light * r_editlights_quakelightsizescale.value * lightscale / fadescale, 1048576); light = sqrt(bound(0, light, 1048576)) * (1.0f / 16.0f); if (color[0] == 1 && color[1] == 1 && color[2] == 1) VectorCopy(overridecolor, color); VectorScale(color, light, color); VectorAdd(origin, originhack, origin); - if (radius >= 15) - R_Shadow_NewWorldLight(origin, angles, color, radius, !!(pflags & 2), style, !(pflags & 1), skin >= 16 ? va("cubemaps/%i", skin) : NULL); + if (radius >= 15 && !(pflags & PFLAGS_FULLDYNAMIC)) + R_Shadow_NewWorldLight(origin, angles, color, radius, (pflags & PFLAGS_CORONA) != 0, style, (pflags & PFLAGS_NOSHADOW) == 0, skin >= 16 ? va("cubemaps/%i", skin) : NULL); } } diff --git a/sv_main.c b/sv_main.c index 71b57193..97669a55 100644 --- a/sv_main.c +++ b/sv_main.c @@ -816,7 +816,29 @@ void SV_PrepareEntitiesForSending(void) cs.lightstyle = (qbyte)GETEDICTFIELDVALUE(ent, eval_style)->_float; cs.lightpflags = (qbyte)GETEDICTFIELDVALUE(ent, eval_pflags)->_float; - cs.specialvisibilityradius = cs.light[3]; + if (gamemode == GAME_TENEBRAE) + { + // tenebrae's EF_FULLDYNAMIC conflicts with Q2's EF_NODRAW + if (cs.effects & 16) + { + cs.effects &= ~16; + cs.lightpflags |= PFLAGS_FULLDYNAMIC; + } + // tenebrae's EF_GREEN conflicts with DP's EF_ADDITIVE + if (cs.effects & 32) + { + cs.effects &= ~32; + cs.light[0] = 0.2; + cs.light[1] = 1; + cs.light[2] = 0.2; + cs.light[3] = 200; + cs.lightpflags |= PFLAGS_FULLDYNAMIC; + } + } + + cs.specialvisibilityradius = 0; + if (cs.lightpflags & PFLAGS_FULLDYNAMIC) + cs.specialvisibilityradius = max(cs.specialvisibilityradius, cs.light[3]); if (cs.glowsize) cs.specialvisibilityradius = max(cs.specialvisibilityradius, cs.glowsize * 4); if (cs.flags & RENDER_GLOWTRAIL) diff --git a/todo b/todo index b531ed5e..0cc3f437 100644 --- a/todo +++ b/todo @@ -30,16 +30,19 @@ d darkplaces: make the WriteEntitiesToClient code call TraceBox directly instead -n darkplaces: net_slist should print out "No network." if networking is not initialized (yummyluv) d darkplaces: noclipping out the ceiling of q3dm17 crashes (Static_Fiend) -n darkplaces: remove dead master server from default masters list (yummyluv) --n darkplaces: revert noclip movement to match nq for compatibility with mods that trap movement as input (MauveBib) +d darkplaces: revert noclip movement to match nq for compatibility with mods that trap movement as input (MauveBib) -n darkplaces: segfault reading memory in windows when starting a new server from menu (yummyluv) -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv) -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv) +d darkplaces: make light_lev dlights from qc require PFLAGS_FULLDYNAMIC flag +d darkplaces: improve tenebrae compatibility by handling EF_FULLDYNAMIC flag in tenebrae mode, also make all sprites render additive +0 darkplaces: figure out why bmodels aren't receiving lightmap dlights d darkplaces: fixed SV_TouchAreaGrid to not crash if SV_IncreaseEdicts is called during a touch function, by making a list of edicts to touch and then running through the list afterward (KGB|romi) d darkplaces: moved R_ShadowVolumeLighting to r_shadow.c d darkplaces: added RENDER_LIGHT flag to entity_render_t to make rtlighting optional per entity d darkplaces: cleaned up rtlight handling, merging most code between world rtlights and dlights d darkplaces: safety checked lightmap access in Mod_Q1BSP_RecursiveLightPoint as one map Sajt uses was crashing (Sajt) --n darkplaces: upgrade network protocol to send precise angles, and make EF_LOWPRECISION downgrade both origin and angles (-Urre, -Wazat for Battlemech, FrikaC, -mashakos, RenegadeC, Sajt) +-n darkplaces: upgrade network protocol to send precise angles, and make EF_LOWPRECISION downgrade both origin and angles (-Urre, -Wazat for Battlemech, FrikaC, mashakos, RenegadeC, Sajt) -n darkplaces: fix cubemap upload scaling crashes (Urre) d darkplaces: make screenshots save to screenshots/fniggium%04i.tga in GAME_FNIGGIUM (Sajt) d darkplaces: make screenshots save to screenshots directory (Sajt) -- 2.39.2