#define ISTELETEX(name) ((name)[0] == '*' && (name)[1] == 't' && (name)[2] == 'e' && (name)[3] == 'l' && (name)[4] == 'e')
/*
=================
Mod_DetectWaterTrans
detect if a model has been vised for translucent water
=================
*/
qboolean Mod_DetectWaterTrans (model_t *mod)
{
int i, j;
byte *vis;
mleaf_t *leaf;
msurface_t **surf;
// no visdata
if (!mod->visdata)
return true;
for (i = 0 ; i < mod->numleafs ; i++)
{
// leaf 0 is the solid leaf, leafs go to numleafs + 1
leaf = &mod->leafs[i+1];
// not interested in these leafs
if (leaf->contents >= CONTENTS_EMPTY || leaf->contents == CONTENTS_SOLID || leaf->contents == CONTENTS_SKY)
continue;
// check marksurfaces for a water texture
surf = leaf->firstmarksurface;
for (j = 0 ; j < leaf->nummarksurfaces ; j++, surf++)
{
// bad surf/texinfo/texture (some old maps have this from a bad qbsp)
if (!surf || !(*surf) || !(*surf)->texinfo || !(*surf)->texinfo->texture)
continue;
// not interested in teleports
if (!ISTELETEX((*surf)->texinfo->texture->name))
goto LeafOK;
}
// no water/etc textures here
continue;
LeafOK:
// get the decompressed vis
vis = Mod_DecompressVis (leaf->compressed_vis, mod);
// check the other leafs
for (j = 0 ; j < mod->numleafs ; j++)
{
// in the PVS
if (vis[j>>3] & (1 << (j & 7)))
{
mleaf_t *visleaf = &mod->leafs[j + 1];
// the leaf we hit originally was under water/slime/lava, and a
// leaf in it's pvs is above water/slime/lava.
if (visleaf->contents == CONTENTS_EMPTY)
return true;
}
}
}
// found nothing
return false;
}
The night is young. How else can I annoy the world before sunsrise? Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
consider: cube in the middle of nowhere. its water, it has no access to any air at all. it does not connect to empty, thus the not water-vised. To fix that you would have to scan every single water leaf's pvs in order to ensure that you don't get a false negative. And that's painful.
Doing it only for leafs that have a water surface will result in better scaling, naming no names some maps can be rather large, and any routine that gets four times as slow as map size merely doubles is bad. Hence the texture check, and then only one leaf's pvs is checks.
Tbh, I'm not sure it would be all that slow, but its not a trivial operation.
Reliablity is probably better than speed here though...
Side note: hexen2 has opaque lava and transparent water.
I curious, how a brush model can have an alpha channel and render without any performance issues, but water cannot. Is it possible to remove water from a map and replace it with something simpler? But still retain the transparency?
if on average, 1% of water leafs have a water surface, and the map size doubles, then you have twice the number of leafs with a water surface, so you still have 4x as much work to do
r00k wrote:I curious, how a brush model can have an alpha channel and render without any performance issues, but water cannot. Is it possible to remove water from a map and replace it with something simpler? But still retain the transparency?
The brush model is a func_wall or other entity? (Meaning it doesn't block vis)
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
For these you have to consider: cube in the middle of nowhere. the water has no access to any air at all. it is not connected to empty, so no water revised. To fix this you must scan all PLWHA single piece of water to ensure that you do not receive a false negative. And it is painful. is the only way for magazines with a water surface will result in better scaling, without mentioning the names of some cards can be very large, and the whole routine gets four times slower than card size only doubles is poor. So check the texture, and a single sheet is PVS is control.
jonyroger wrote:For these you have to consider: cube in the middle of nowhere. the water has no access to any air at all. it is not connected to empty, so no water revised. To fix this you must scan all PLWHA single piece of water to ensure that you do not receive a false negative. And it is painful. is the only way for magazines with a water surface will result in better scaling, without mentioning the names of some cards can be very large, and the whole routine gets four times slower than card size only doubles is poor. So check the texture, and a single sheet is PVS is control.
You sir, have completed your degree in horseshitology from the distinguished University of Phoenix and should be a very proud spambot, indeed!
Congrats in being some Meixcan making 0.02 cents an hour and actually knowing some of the right words.
*Sniff*
I'm gonna miss you.
The night is young. How else can I annoy the world before sunsrise? Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..