From f81bcf7482d2f346e74f8c1a8131796a7db45665 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 21 Jan 2007 23:12:20 +0000 Subject: [PATCH] autodetect whether a map supports transparent water at load time git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6716 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 5 +++-- model_brush.c | 26 ++++++++++++++++++++++++++ model_shared.h | 2 ++ todo | 4 ++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index af26ca6f..3ca1f219 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2484,13 +2484,14 @@ static void R_Texture_AddLayer(texture_t *t, qboolean depthmask, int blendfunc1, void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) { + model_t *model = ent->model; + // FIXME: identify models using a better check than ent->model->brush.shadowmesh //int lightmode = ((ent->effects & EF_FULLBRIGHT) || ent->model->brush.shadowmesh) ? 0 : 2; // switch to an alternate material if this is a q1bsp animated material { texture_t *texture = t; - model_t *model = ent->model; int s = ent->skinnum; if ((unsigned int)s >= (unsigned int)model->numskins) s = 0; @@ -2521,7 +2522,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) t->currentmaterialflags = t->basematerialflags; t->currentalpha = ent->alpha; - if (t->basematerialflags & MATERIALFLAG_WATERALPHA) + if (t->basematerialflags & MATERIALFLAG_WATERALPHA && (model->brush.supportwateralpha || r_novis.integer)) t->currentalpha *= r_wateralpha.value; if (!(ent->flags & RENDER_LIGHT)) t->currentmaterialflags |= MATERIALFLAG_FULLBRIGHT; diff --git a/model_brush.c b/model_brush.c index 8f907bfb..15402553 100644 --- a/model_brush.c +++ b/model_brush.c @@ -2368,6 +2368,26 @@ static void Mod_Q1BSP_LoadLeafs(lump_t *l) } } +qboolean Mod_Q1BSP_CheckWaterAlphaSupport(void) +{ + int i, j; + mleaf_t *leaf; + const unsigned char *pvs; + // check all liquid leafs to see if they can see into empty leafs, if any + // can we can assume this map supports r_wateralpha + for (i = 0, leaf = loadmodel->brush.data_leafs;i < loadmodel->brush.num_leafs;i++, leaf++) + { + if ((leaf->contents == CONTENTS_WATER || leaf->contents == CONTENTS_SLIME) && (leaf->clusterindex >= 0 && loadmodel->brush.data_pvsclusters)) + { + pvs = loadmodel->brush.data_pvsclusters + leaf->clusterindex * loadmodel->brush.num_pvsclusterbytes; + for (j = 0;j < loadmodel->brush.num_leafs;j++) + if (leaf->contents == CONTENTS_EMPTY && CHECKPVSBIT(pvs, loadmodel->brush.data_leafs[j].clusterindex)) + return true; + } + } + return false; +} + static void Mod_Q1BSP_LoadClipnodes(lump_t *l, hullinfo_t *hullinfo) { dclipnode_t *in, *out; @@ -3284,6 +3304,9 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) Mod_Q1BSP_LoadNodes(&header->lumps[LUMP_NODES]); Mod_Q1BSP_LoadClipnodes(&header->lumps[LUMP_CLIPNODES], &hullinfo); + // check if the map supports transparent water rendering + loadmodel->brush.supportwateralpha = Mod_Q1BSP_CheckWaterAlphaSupport(); + if (!mod->brushq1.lightdata) mod->brush.LightPoint = NULL; @@ -5774,6 +5797,9 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer, void *bufferend) // the MakePortals code works fine on the q3bsp data as well Mod_Q1BSP_MakePortals(); + // FIXME: shader alpha should replace r_wateralpha support in q3bsp + loadmodel->brush.supportwateralpha = true; + // make a single combined shadow mesh to allow optimized shadow volume creation numshadowmeshtriangles = 0; for (j = 0, surface = loadmodel->data_surfaces;j < loadmodel->num_surfaces;j++, surface++) diff --git a/model_shared.h b/model_shared.h index 6196835e..8b0af273 100644 --- a/model_shared.h +++ b/model_shared.h @@ -394,6 +394,8 @@ typedef struct model_brush_s rtexture_t *solidskytexture; rtexture_t *alphaskytexture; + qboolean supportwateralpha; + // QuakeWorld int qw_md4sum; int qw_md4sum2; diff --git a/todo b/todo index b7b88bb6..d3a55d4a 100644 --- a/todo +++ b/todo @@ -31,10 +31,9 @@ -d (steven a) bug darkplaces server: Blood Mage monsters are stuck in place apparently (steven a) -d (yummyluv) feature darkplaces protocol: add EF_DOUBLESIDED for double sided entity rendering (disable cull face for this entity) (yummyluv) -d (yummyluv) feature darkplaces protocol: add buttons 9-16 (yummyluv) +-d bug darkplaces client: GAME_NEHAHRA: make sure cutscenes and movies work, got a report of seeing a black screen (NightFright) -f (James D) bug darkplaces server: losing runes on episode completion, completing episode 1 then 2 then 3 causes it to forget 1, then 4 causes it to forget 2 and 3, making it impossible to open the boss gate (James D) -f (Wazat) bug darkplaces: client's slowmo detection (measuring packet times and comparing to game time changes) may be making the game unpleasant (Wazat) -0 bug darkplaces client: GAME_NEHAHRA: make sure cutscenes and movies work, got a report of seeing a black screen (NightFright) -0 bug darkplaces client: hipnotic: health is one character to the right on the sbar, covering up the key icons (M`Shacron) 0 bug darkplaces client: it has been reported that sometimes level changes on quakeworld servers don't load a map, this may be related to downloading? (Baker) 0 bug darkplaces client: on crctf proquake servers the scoreboard does not contain exactly matching player names (READY is sometimes appended), the ping report and status parsing should ignore text after the player name 0 bug darkplaces client: svc_effect should post a warning and do nothing if given a framerate below 1 (Willis) @@ -530,6 +529,7 @@ d bug darkplaces client: do replay cl_movement queue each time a move is added, d bug darkplaces client: figure out why multimap demos are skipping the later portions, it's probably related to the time seeking, probably not being reset (Urre) d bug darkplaces client: finale text during episode-end intermissions shows briefly in its entirety and all as one line (going off the screen), then disappears and begins typing slowly as it should (Sajt) d bug darkplaces client: fix cl_bobmodel bug which momentarily jolts the gun when you pass through a trigger, pick up an item, etc, Sajt thinks this is related to console prints as well as centerprint (Sajt) +d bug darkplaces client: hipnotic: health is one character to the right on the sbar, covering up the key icons (M`Shacron) d bug darkplaces client: make "wait" command wait fornext network frame somehow when connected, to make frikbot .way files load properly (Transfusion, FrikaC) d bug darkplaces client: make envmap command work with the corrected layout d bug darkplaces client: make server queries use a queue to avoid flooding out queries too fast (Willis) -- 2.39.2