implemented DP_EF_NODEPTHTEST extension
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 28 Sep 2004 06:38:45 +0000 (06:38 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 28 Sep 2004 06:38:45 +0000 (06:38 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4560 d7cf8633-e32d-0410-b094-e92efae38249

cl_main.c
gl_models.c
gl_rmain.c
gl_rsurf.c
pr_cmds.c
protocol.h
r_shadow.c
r_sprites.c
sv_main.c

index 036a924..59f7437 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -534,7 +534,7 @@ void CL_LinkNetworkEntity(entity_t *e)
                        if (e == &cl.viewent && cl.viewentity >= 0 && cl.viewentity < MAX_EDICTS && cl_entities[cl.viewentity].state_current.active)
                        {
                                e->state_current.alpha = cl_entities[cl.viewentity].state_current.alpha;
-                               e->state_current.effects = EF_NOSHADOW | (cl_entities[cl.viewentity].state_current.effects & (EF_ADDITIVE | EF_REFLECTIVE | EF_FULLBRIGHT));
+                               e->state_current.effects = EF_NOSHADOW | (cl_entities[cl.viewentity].state_current.effects & (EF_ADDITIVE | EF_REFLECTIVE | EF_FULLBRIGHT | EF_NODEPTHTEST));
                        }
                }
                else
@@ -853,7 +853,7 @@ void CL_LinkNetworkEntity(entity_t *e)
                if (e - cl_entities == cl.viewentity)
                        e->render.flags |= RENDER_EXTERIORMODEL;
                // transparent stuff can't be lit during the opaque stage
-               if (e->render.effects & (EF_ADDITIVE) || e->render.alpha < 1)
+               if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
                        e->render.flags |= RENDER_TRANSPARENT;
                // either fullbright or lit
                if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
@@ -903,7 +903,7 @@ static void CL_RelinkStaticEntities(void)
                Mod_CheckLoaded(e->render.model);
                e->render.flags = 0;
                // transparent stuff can't be lit during the opaque stage
-               if (e->render.effects & (EF_ADDITIVE) || e->render.alpha < 1)
+               if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
                        e->render.flags |= RENDER_TRANSPARENT;
                // either fullbright or lit
                if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
index f05c9ef..f2d8b3a 100644 (file)
@@ -104,7 +104,7 @@ void R_DrawAliasModelCallback (const void *calldata1, int calldata2)
                        GL_BlendFunc(GL_ONE, GL_ZERO);
                        GL_DepthMask(true);
                }
-               GL_DepthTest(true);
+               GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
                firstpass = false;
                colorscale = 1.0f;
 
@@ -181,7 +181,7 @@ void R_Model_Alias_Draw(entity_render_t *ent)
        for (meshnum = 0, mesh = ent->model->alias.aliasdata_meshes;meshnum < ent->model->alias.aliasnum_meshes;meshnum++, mesh++)
        {
                if (ent->effects & EF_ADDITIVE || ent->alpha != 1.0 || R_FetchAliasSkin(ent, mesh)->flags & ALIASSKIN_TRANSPARENT)
-                       R_MeshQueue_AddTransparent(ent->origin, R_DrawAliasModelCallback, ent, meshnum);
+                       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : ent->origin, R_DrawAliasModelCallback, ent, meshnum);
                else
                        R_DrawAliasModelCallback(ent, meshnum);
        }
index 2f9d3f3..fc97f48 100644 (file)
@@ -453,7 +453,7 @@ static void R_MarkEntities (void)
                R_LerpAnimation(ent);
                R_UpdateEntLights(ent);
                if ((chase_active.integer || !(ent->flags & RENDER_EXTERIORMODEL))
-                && !VIS_CullBox(ent->mins, ent->maxs)
+                && (!VIS_CullBox(ent->mins, ent->maxs) || (ent->effects & EF_NODEPTHTEST))
                 && (!envmap || !(ent->flags & (RENDER_VIEWMODEL | RENDER_EXTERIORMODEL))))
                        ent->visframe = r_framecount;
        }
@@ -836,7 +836,7 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2)
                GL_BlendFunc(GL_ONE, GL_ZERO);
                GL_DepthMask(true);
        }
-       GL_DepthTest(true);
+       GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
        if (fogenabled)
        {
                memcpy(color4f, nomodelcolor4f, sizeof(float[6*4]));
@@ -868,7 +868,7 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2)
 void R_DrawNoModel(entity_render_t *ent)
 {
        //if ((ent->effects & EF_ADDITIVE) || (ent->alpha < 1))
-               R_MeshQueue_AddTransparent(ent->origin, R_DrawNoModelCallback, ent, 0);
+               R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : ent->origin, R_DrawNoModelCallback, ent, 0);
        //else
        //      R_DrawNoModelCallback(ent, 0);
 }
index 9abcc65..136e8ec 100644 (file)
@@ -725,6 +725,9 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture
        // LordHavoc: HalfLife maps have freaky skypolys...
        if (ent->model->brush.ishlbsp)
                return;
+       // sky rendering transparently would be too difficult
+       if (ent->flags & RENDER_TRANSPARENT)
+               return;
 
        if (skyrendernow)
        {
@@ -789,7 +792,7 @@ static void RSurfShader_Transparent_Callback(const void *calldata1, int calldata
        if (surf->flags & SURF_WATERALPHA)
                currentalpha *= r_wateralpha.value;
 
-       GL_DepthTest(true);
+       GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
        if (ent->effects & EF_ADDITIVE)
        {
                rendertype = SURFRENDER_ADD;
@@ -806,7 +809,7 @@ static void RSurfShader_Transparent_Callback(const void *calldata1, int calldata
        {
                rendertype = SURFRENDER_OPAQUE;
                GL_BlendFunc(GL_ONE, GL_ZERO);
-               GL_DepthMask(true);
+               GL_DepthMask(!(ent->effects & EF_NODEPTHTEST));
        }
 
        turb = (surf->flags & SURF_DRAWTURB) && r_waterscroll.value;
@@ -1360,7 +1363,7 @@ void R_DrawSurfaces(entity_render_t *ent, int flagsmask)
                                                if (surf->visframe == r_framecount)
                                                {
                                                        Matrix4x4_Transform(&ent->matrix, surf->poly_center, center);
-                                                       R_MeshQueue_AddTransparent(center, RSurfShader_Transparent_Callback, ent, surf - ent->model->brushq1.surfaces);
+                                                       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : center, RSurfShader_Transparent_Callback, ent, surf - ent->model->brushq1.surfaces);
                                                }
                                        }
                                }
@@ -1412,7 +1415,7 @@ void R_DrawSurfaces(entity_render_t *ent, int flagsmask)
                                                else
                                                {
                                                        Matrix4x4_Transform(&ent->matrix, surf->poly_center, center);
-                                                       R_MeshQueue_AddTransparent(center, RSurfShader_Transparent_Callback, ent, surf - ent->model->brushq1.surfaces);
+                                                       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : center, RSurfShader_Transparent_Callback, ent, surf - ent->model->brushq1.surfaces);
                                                }
                                        }
                                }
@@ -1919,6 +1922,9 @@ void R_Q3BSP_DrawSkyFace(entity_render_t *ent, q3msurface_t *face)
        rmeshstate_t m;
        if (!face->num_triangles)
                return;
+       // drawing sky transparently would be too difficult
+       if (ent->flags & RENDER_TRANSPARENT)
+               return;
        c_faces++;
        if (skyrendernow)
        {
@@ -2171,7 +2177,7 @@ void R_Q3BSP_DrawFace_TransparentCallback(const void *voident, int facenumber)
        else
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
-       GL_DepthTest(true);
+       GL_DepthTest(!(ent->effects & EF_NODEPTHTEST));
        m.tex[0] = R_GetTexture(face->texture->skin.base);
        m.pointer_texcoord[0] = face->data_texcoordtexture2f;
        colorscale = r_lightmapintensity;
@@ -2210,7 +2216,7 @@ void R_Q3BSP_DrawFace(entity_render_t *ent, q3msurface_t *face)
                facecenter[1] = (face->mins[1] + face->maxs[1]) * 0.5f;
                facecenter[2] = (face->mins[2] + face->maxs[2]) * 0.5f;
                Matrix4x4_Transform(&ent->matrix, facecenter, center);
-               R_MeshQueue_AddTransparent(center, R_Q3BSP_DrawFace_TransparentCallback, ent, face - ent->model->brushq3.data_faces);
+               R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : center, R_Q3BSP_DrawFace_TransparentCallback, ent, face - ent->model->brushq3.data_faces);
                return;
        }
        R_Mesh_Matrix(&ent->matrix);
index 8bdb8f0..17cb6c9 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -75,6 +75,7 @@ char *ENGINE_EXTENSIONS =
 "DP_EF_BLUE "
 "DP_EF_FLAME "
 "DP_EF_FULLBRIGHT "
+"DP_EF_NODEPTHTEST "
 "DP_EF_NODRAW "
 "DP_EF_NOSHADOW "
 "DP_EF_RED "
index db5687c..1e78cf3 100644 (file)
@@ -69,6 +69,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define EF_FLAME                               1024    // LordHavoc: on fire
 #define EF_STARDUST                            2048    // LordHavoc: showering sparks
 #define EF_NOSHADOW                            4096    // LordHavoc: does not cast a shadow
+#define EF_NODEPTHTEST                 8192    // LordHavoc: shows through walls
 
 #define EF_STEP                                        0x80000000 // internal client use only - present on MOVETYPE_STEP entities, not QC accessible (too many bits)
 
index 22156ee..79023e7 100644 (file)
@@ -1290,6 +1290,7 @@ void R_Shadow_RenderLighting(int numverts, int numtriangles, const int *elements
                bumptexture = r_shadow_blankbumptexture;
        if (!glosstexture)
                glosstexture = r_shadow_blankglosstexture;
+       // FIXME: support EF_NODEPTHTEST
        GL_DepthMask(false);
        GL_DepthTest(true);
        if (gl_dot3arb && gl_texturecubemap && gl_combine.integer && gl_stencil)
index 906bcac..f3c8a33 100644 (file)
@@ -147,6 +147,6 @@ void R_Model_Sprite_Draw(entity_render_t *ent)
 
        c_sprites++;
 
-       R_MeshQueue_AddTransparent(ent->origin, R_DrawSpriteModelCallback, ent, 0);
+       R_MeshQueue_AddTransparent(ent->effects & EF_NODEPTHTEST ? r_vieworigin : ent->origin, R_DrawSpriteModelCallback, ent, 0);
 }
 
index c79ee24..b0f4f2a 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -624,7 +624,7 @@ void SV_MarkWriteEntityStateToClient(entity_state_t *s)
                }
                // always send world submodels, they don't generate much traffic
                // except in PROTOCOL_QUAKE where they hog bandwidth like crazy
-               else if (!(isbmodel = (model = sv.models[s->modelindex]) != NULL && model->name[0] == '*') || sv.protocol == PROTOCOL_QUAKE)
+               else if ((!(isbmodel = (model = sv.models[s->modelindex]) != NULL && model->name[0] == '*') && !(s->effects & EF_NODEPTHTEST)) || sv.protocol == PROTOCOL_QUAKE)
                {
                        Mod_CheckLoaded(model);
                        // entity has survived every check so far, check if visible