now uses q3bsp surfaceflags when possible instead of shaders (but the trans flag...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 30 Nov 2003 06:33:33 +0000 (06:33 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 30 Nov 2003 06:33:33 +0000 (06:33 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3673 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c
model_brush.c
model_shared.h
r_shadow.c

index fc7a2c1..94622dc 100644 (file)
@@ -2022,13 +2022,11 @@ void R_Q3BSP_DrawFace(entity_render_t *ent, q3mface_t *face)
                return;
        if (face->texture->surfaceparms)
        {
-               if (face->texture->surfaceparms & SURFACEPARM_SKY)
-                       return;
-               if (face->texture->surfaceparms & SURFACEPARM_NODRAW)
+               if (face->texture->surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NODRAW))
                        return;
        }
        face->visframe = r_framecount;
-       if ((face->texture->surfaceparms & SURFACEPARM_TRANS) || ent->alpha < 1 || (ent->effects & EF_ADDITIVE))
+       if ((face->texture->surfaceparms & Q3SURFACEPARM_TRANS) || ent->alpha < 1 || (ent->effects & EF_ADDITIVE))
        {
                vec3_t facecenter, center;
                facecenter[0] = (face->mins[0] + face->maxs[0]) * 0.5f;
@@ -2110,12 +2108,12 @@ void R_Q3BSP_DrawSky(entity_render_t *ent)
                                R_Q3BSP_RecursiveWorldNode(ent, model->brushq3.data_nodes, modelorg, pvs, r_framecount);
                        }
                        for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
-                               if (face->markframe == r_framecount && (face->texture->surfaceparms & SURFACEPARM_SKY) && !R_CullBox(face->mins, face->maxs))
+                               if (face->markframe == r_framecount && (face->texture->surfaceflags & Q3SURFACEFLAG_SKY) && !R_CullBox(face->mins, face->maxs))
                                        R_Q3BSP_DrawSkyFace(ent, face);
                }
                else
                        for (i = 0, face = model->brushq3.data_thismodel->firstface;i < model->brushq3.data_thismodel->numfaces;i++, face++)
-                               if ((face->texture->surfaceparms & SURFACEPARM_SKY))
+                               if ((face->texture->surfaceflags & Q3SURFACEFLAG_SKY))
                                        R_Q3BSP_DrawSkyFace(ent, face);
        }
 }
@@ -2191,7 +2189,7 @@ void R_Q3BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
 
 void R_Q3BSP_DrawFaceLight(entity_render_t *ent, q3mface_t *face, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltofilter, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz)
 {
-       if ((face->texture->surfaceparms & SURFACEPARM_NODRAW) || !face->num_triangles)
+       if ((face->texture->surfaceflags & Q3SURFACEFLAG_NODRAW) || !face->num_triangles)
                return;
        R_Shadow_DiffuseLighting(face->num_vertices, face->num_triangles, face->data_element3i, face->data_vertex3f, face->data_svector3f, face->data_tvector3f, face->data_normal3f, face->data_texcoordtexture2f, relativelightorigin, lightradius, lightcolor, matrix_modeltofilter, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, face->texture->skin.base, face->texture->skin.nmap, NULL);
        R_Shadow_SpecularLighting(face->num_vertices, face->num_triangles, face->data_element3i, face->data_vertex3f, face->data_svector3f, face->data_tvector3f, face->data_normal3f, face->data_texcoordtexture2f, relativelightorigin, relativeeyeorigin, lightradius, lightcolor, matrix_modeltofilter, matrix_modeltoattenuationxyz, matrix_modeltoattenuationz, face->texture->skin.gloss, face->texture->skin.nmap, NULL);
index 0240883..7a5257b 100644 (file)
@@ -3308,7 +3308,8 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l)
 {
        q3dtexture_t *in;
        q3mtexture_t *out;
-       int i, j, count, c;
+       int i, count;
+       int j, c;
        fssearch_t *search;
        char *f;
        const char *text;
@@ -3366,57 +3367,57 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l)
                                                                if (COM_ParseToken(&text, true) && strcmp(com_token, "\n"))
                                                                {
                                                                        if (!strcmp(com_token, "alphashadow"))
-                                                                               flags |= SURFACEPARM_ALPHASHADOW;
+                                                                               flags |= Q3SURFACEPARM_ALPHASHADOW;
                                                                        else if (!strcmp(com_token, "areaportal"))
-                                                                               flags |= SURFACEPARM_AREAPORTAL;
+                                                                               flags |= Q3SURFACEPARM_AREAPORTAL;
                                                                        else if (!strcmp(com_token, "clusterportal"))
-                                                                               flags |= SURFACEPARM_CLUSTERPORTAL;
+                                                                               flags |= Q3SURFACEPARM_CLUSTERPORTAL;
                                                                        else if (!strcmp(com_token, "detail"))
-                                                                               flags |= SURFACEPARM_DETAIL;
+                                                                               flags |= Q3SURFACEPARM_DETAIL;
                                                                        else if (!strcmp(com_token, "donotenter"))
-                                                                               flags |= SURFACEPARM_DONOTENTER;
+                                                                               flags |= Q3SURFACEPARM_DONOTENTER;
                                                                        else if (!strcmp(com_token, "fog"))
-                                                                               flags |= SURFACEPARM_FOG;
+                                                                               flags |= Q3SURFACEPARM_FOG;
                                                                        else if (!strcmp(com_token, "lava"))
-                                                                               flags |= SURFACEPARM_LAVA;
+                                                                               flags |= Q3SURFACEPARM_LAVA;
                                                                        else if (!strcmp(com_token, "lightfilter"))
-                                                                               flags |= SURFACEPARM_LIGHTFILTER;
+                                                                               flags |= Q3SURFACEPARM_LIGHTFILTER;
                                                                        else if (!strcmp(com_token, "metalsteps"))
-                                                                               flags |= SURFACEPARM_METALSTEPS;
+                                                                               flags |= Q3SURFACEPARM_METALSTEPS;
                                                                        else if (!strcmp(com_token, "nodamage"))
-                                                                               flags |= SURFACEPARM_NODAMAGE;
+                                                                               flags |= Q3SURFACEPARM_NODAMAGE;
                                                                        else if (!strcmp(com_token, "nodlight"))
-                                                                               flags |= SURFACEPARM_NODLIGHT;
+                                                                               flags |= Q3SURFACEPARM_NODLIGHT;
                                                                        else if (!strcmp(com_token, "nodraw"))
-                                                                               flags |= SURFACEPARM_NODRAW;
+                                                                               flags |= Q3SURFACEPARM_NODRAW;
                                                                        else if (!strcmp(com_token, "nodrop"))
-                                                                               flags |= SURFACEPARM_NODROP;
+                                                                               flags |= Q3SURFACEPARM_NODROP;
                                                                        else if (!strcmp(com_token, "noimpact"))
-                                                                               flags |= SURFACEPARM_NOIMPACT;
+                                                                               flags |= Q3SURFACEPARM_NOIMPACT;
                                                                        else if (!strcmp(com_token, "nolightmap"))
-                                                                               flags |= SURFACEPARM_NOLIGHTMAP;
+                                                                               flags |= Q3SURFACEPARM_NOLIGHTMAP;
                                                                        else if (!strcmp(com_token, "nomarks"))
-                                                                               flags |= SURFACEPARM_NOMARKS;
+                                                                               flags |= Q3SURFACEPARM_NOMARKS;
                                                                        else if (!strcmp(com_token, "nomipmaps"))
-                                                                               flags |= SURFACEPARM_NOMIPMAPS;
+                                                                               flags |= Q3SURFACEPARM_NOMIPMAPS;
                                                                        else if (!strcmp(com_token, "nonsolid"))
-                                                                               flags |= SURFACEPARM_NONSOLID;
+                                                                               flags |= Q3SURFACEPARM_NONSOLID;
                                                                        else if (!strcmp(com_token, "origin"))
-                                                                               flags |= SURFACEPARM_ORIGIN;
+                                                                               flags |= Q3SURFACEPARM_ORIGIN;
                                                                        else if (!strcmp(com_token, "playerclip"))
-                                                                               flags |= SURFACEPARM_PLAYERCLIP;
+                                                                               flags |= Q3SURFACEPARM_PLAYERCLIP;
                                                                        else if (!strcmp(com_token, "sky"))
-                                                                               flags |= SURFACEPARM_SKY;
+                                                                               flags |= Q3SURFACEPARM_SKY;
                                                                        else if (!strcmp(com_token, "slick"))
-                                                                               flags |= SURFACEPARM_SLICK;
+                                                                               flags |= Q3SURFACEPARM_SLICK;
                                                                        else if (!strcmp(com_token, "slime"))
-                                                                               flags |= SURFACEPARM_SLIME;
+                                                                               flags |= Q3SURFACEPARM_SLIME;
                                                                        else if (!strcmp(com_token, "structural"))
-                                                                               flags |= SURFACEPARM_STRUCTURAL;
+                                                                               flags |= Q3SURFACEPARM_STRUCTURAL;
                                                                        else if (!strcmp(com_token, "trans"))
-                                                                               flags |= SURFACEPARM_TRANS;
+                                                                               flags |= Q3SURFACEPARM_TRANS;
                                                                        else if (!strcmp(com_token, "water"))
-                                                                               flags |= SURFACEPARM_WATER;
+                                                                               flags |= Q3SURFACEPARM_WATER;
                                                                        else
                                                                                Con_Printf("%s parsing warning: unknown surfaceparm \"%s\"\n", search->filenames[i], com_token);
                                                                        if (!COM_ParseToken(&text, true) || strcmp(com_token, "\n"))
@@ -3469,11 +3470,11 @@ parseerror:
                        // these are defaults
                        if (!strcmp(out->name, "caulk") || !strcmp(out->name, "common/caulk") || !strcmp(out->name, "textures/common/caulk")
                         || !strcmp(out->name, "nodraw") || !strcmp(out->name, "common/nodraw") || !strcmp(out->name, "textures/common/nodraw"))
-                               out->surfaceparms |= SURFACEPARM_NODRAW;
+                               out->surfaceparms |= Q3SURFACEPARM_NODRAW;
                        if (!strncmp(out->name, "textures/skies/", 15))
-                               out->surfaceparms |= SURFACEPARM_SKY;
+                               out->surfaceparms |= Q3SURFACEPARM_SKY;
                        if (R_TextureHasAlpha(out->skin.base))
-                               out->surfaceparms |= SURFACEPARM_TRANS;
+                               out->surfaceparms |= Q3SURFACEPARM_TRANS;
                }
        }
        Con_DPrintf("%s: %i textures missing shaders\n", loadmodel->name, c);
@@ -4817,7 +4818,7 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer)
                mod->radius2 = modelradius * modelradius;
 
                for (j = 0;j < mod->brushq3.data_thismodel->numfaces;j++)
-                       if (mod->brushq3.data_thismodel->firstface[j].texture->surfaceparms & SURFACEPARM_SKY)
+                       if (mod->brushq3.data_thismodel->firstface[j].texture->surfaceflags & Q3SURFACEFLAG_SKY)
                                break;
                if (j < mod->brushq3.data_thismodel->numfaces)
                        mod->DrawSky = R_Q3BSP_DrawSky;
index e1d63e9..4e02923 100644 (file)
@@ -279,33 +279,54 @@ typedef struct model_brushq2_s
 model_brushq2_t;
 */
 
-
-#define SURFACEPARM_ALPHASHADOW 1
-#define SURFACEPARM_AREAPORTAL 2
-#define SURFACEPARM_CLUSTERPORTAL 4
-#define SURFACEPARM_DETAIL 8
-#define SURFACEPARM_DONOTENTER 16
-#define SURFACEPARM_FOG 32
-#define SURFACEPARM_LAVA 64
-#define SURFACEPARM_LIGHTFILTER 128
-#define SURFACEPARM_METALSTEPS 256
-#define SURFACEPARM_NODAMAGE 512
-#define SURFACEPARM_NODLIGHT 1024
-#define SURFACEPARM_NODRAW 2048
-#define SURFACEPARM_NODROP 4096
-#define SURFACEPARM_NOIMPACT 8192
-#define SURFACEPARM_NOLIGHTMAP 16384
-#define SURFACEPARM_NOMARKS 32768
-#define SURFACEPARM_NOMIPMAPS 65536
-#define SURFACEPARM_NONSOLID 131072
-#define SURFACEPARM_ORIGIN 262144
-#define SURFACEPARM_PLAYERCLIP 524288
-#define SURFACEPARM_SKY 1048576
-#define SURFACEPARM_SLICK 2197152
-#define SURFACEPARM_SLIME 4194304
-#define SURFACEPARM_STRUCTURAL 8388608
-#define SURFACEPARM_TRANS 16777216
-#define SURFACEPARM_WATER 33554432
+// surfaceflags from bsp
+#define Q3SURFACEFLAG_NODAMAGE 1
+#define Q3SURFACEFLAG_SLICK 2
+#define Q3SURFACEFLAG_SKY 4
+#define Q3SURFACEFLAG_LADDER 8
+#define Q3SURFACEFLAG_NOIMPACT 16
+#define Q3SURFACEFLAG_NOMARKS 32
+#define Q3SURFACEFLAG_FLESH 64
+#define Q3SURFACEFLAG_NODRAW 128
+#define Q3SURFACEFLAG_HINT 256
+#define Q3SURFACEFLAG_SKIP 512
+#define Q3SURFACEFLAG_NOLIGHTMAP 1024
+#define Q3SURFACEFLAG_POINTLIGHT 2048
+#define Q3SURFACEFLAG_METALSTEPS 4096
+#define Q3SURFACEFLAG_NOSTEPS 8192
+#define Q3SURFACEFLAG_NONSOLID 16384
+#define Q3SURFACEFLAG_LIGHTFILTER 32768
+#define Q3SURFACEFLAG_ALPHASHADOW 65536
+#define Q3SURFACEFLAG_NODLIGHT 131072
+#define Q3SURFACEFLAG_DUST 262144
+
+// surfaceparms from shaders
+#define Q3SURFACEPARM_ALPHASHADOW 1
+#define Q3SURFACEPARM_AREAPORTAL 2
+#define Q3SURFACEPARM_CLUSTERPORTAL 4
+#define Q3SURFACEPARM_DETAIL 8
+#define Q3SURFACEPARM_DONOTENTER 16
+#define Q3SURFACEPARM_FOG 32
+#define Q3SURFACEPARM_LAVA 64
+#define Q3SURFACEPARM_LIGHTFILTER 128
+#define Q3SURFACEPARM_METALSTEPS 256
+#define Q3SURFACEPARM_NODAMAGE 512
+#define Q3SURFACEPARM_NODLIGHT 1024
+#define Q3SURFACEPARM_NODRAW 2048
+#define Q3SURFACEPARM_NODROP 4096
+#define Q3SURFACEPARM_NOIMPACT 8192
+#define Q3SURFACEPARM_NOLIGHTMAP 16384
+#define Q3SURFACEPARM_NOMARKS 32768
+#define Q3SURFACEPARM_NOMIPMAPS 65536
+#define Q3SURFACEPARM_NONSOLID 131072
+#define Q3SURFACEPARM_ORIGIN 262144
+#define Q3SURFACEPARM_PLAYERCLIP 524288
+#define Q3SURFACEPARM_SKY 1048576
+#define Q3SURFACEPARM_SLICK 2197152
+#define Q3SURFACEPARM_SLIME 4194304
+#define Q3SURFACEPARM_STRUCTURAL 8388608
+#define Q3SURFACEPARM_TRANS 16777216
+#define Q3SURFACEPARM_WATER 33554432
 
 typedef struct q3mtexture_s
 {
index 7372526..01e0c30 100644 (file)
@@ -1877,12 +1877,12 @@ void R_Shadow_NewWorldLight(vec3_t origin, float radius, vec3_t color, int style
                                if (face->lighttemp_castshadow)
                                {
                                        face->lighttemp_castshadow = false;
-                                       if (!(face->texture->surfaceparms & (SURFACEPARM_NODRAW | SURFACEPARM_SKY)))
+                                       if (!(face->texture->surfaceflags & (Q3SURFACEFLAG_NODRAW | Q3SURFACEFLAG_SKY)))
                                        {
                                                if (e->castshadows)
                                                        if (!(face->texture->nativecontents & CONTENTSQ3_TRANSLUCENT))
                                                                Mod_ShadowMesh_AddMesh(r_shadow_mempool, castmesh, NULL, NULL, NULL, face->data_vertex3f, NULL, NULL, NULL, NULL, face->num_triangles, face->data_element3i);
-                                               if (!(face->texture->surfaceparms & SURFACEPARM_SKY))
+                                               if (!(face->texture->surfaceflags & Q3SURFACEFLAG_SKY))
                                                        Mod_ShadowMesh_AddMesh(r_shadow_mempool, e->meshchain_light, face->texture->skin.base, face->texture->skin.gloss, face->texture->skin.nmap, face->data_vertex3f, face->data_svector3f, face->data_tvector3f, face->data_normal3f, face->data_texcoordtexture2f, face->num_triangles, face->data_element3i);
                                        }
                                }