changed behavior about 'Bad Surfaces Extents', now only a warning, and such surfaces...
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 16 Jan 2002 20:31:44 +0000 (20:31 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 16 Jan 2002 20:31:44 +0000 (20:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1350 d7cf8633-e32d-0410-b094-e92efae38249

buildnumber.c
gl_rsurf.c
model_brush.c
model_brush.h

index dd8368b94d8b9ebd8c9fb9acb1d7f1b4e15683e7..4124bfc81906ee642eecaf2cf4a313357045a9a3 100644 (file)
@@ -1,4 +1,4 @@
 
 
-#define BUILDNUMBER 609
+#define BUILDNUMBER 619
 
 int buildnumber = BUILDNUMBER;
 
 int buildnumber = BUILDNUMBER;
index 336cde393d1cec3ab6f6ad8be8a279d3b8c17d9c..b0650a996f2bfb6e75d74b2e0f45cab8a2ee8a48 100644 (file)
@@ -1019,6 +1019,66 @@ static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *s)
        R_Mesh_Draw(&m);
 }
 
        R_Mesh_Draw(&m);
 }
 
+static void RSurfShader_Wall_Pass_BaseFullbright(msurface_t *s)
+{
+       int                             i;
+       float                   diff[3], ifog;
+       surfvertex_t    *v;
+       surfvert_t              *sv;
+       rmeshinfo_t             m;
+
+       memset(&m, 0, sizeof(m));
+       if (currentrenderentity->effects & EF_ADDITIVE)
+       {
+               m.transparent = true;
+               m.blendfunc1 = GL_SRC_ALPHA;
+               m.blendfunc2 = GL_ONE;
+       }
+       else if (currentrenderentity != &cl_entities[0].render && (s->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1))
+       {
+               m.transparent = true;
+               m.blendfunc1 = GL_SRC_ALPHA;
+               m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
+       }
+       else
+       {
+               m.transparent = false;
+               m.blendfunc1 = GL_ONE;
+               m.blendfunc2 = GL_ZERO;
+       }
+       m.numtriangles = s->mesh.numtriangles;
+       m.numverts = s->mesh.numverts;
+       m.index = s->mesh.index;
+       m.vertex = &svert[0].v[0];
+       m.vertexstep = sizeof(surfvert_t);
+       m.tex[0] = R_GetTexture(s->currenttexture->texture);
+       m.texcoords[0] = &s->mesh.vertex->st[0];
+       m.texcoordstep[0] = sizeof(surfvertex_t);
+       if (fogenabled)
+       {
+               m.color = &svert[0].c[0];
+               m.colorstep = sizeof(surfvert_t);
+               for (i = 0, sv = svert, v = s->mesh.vertex;i < m.numverts;i++, sv++, v++)
+               {
+                       softwaretransform(v->v, sv->v);
+                       VectorSubtract(sv->v, r_origin, diff);
+                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
+                       sv->c[0] = ifog;
+                       sv->c[1] = ifog;
+                       sv->c[2] = ifog;
+                       sv->c[3] = currentrenderentity->alpha;
+               }
+       }
+       else
+       {
+               m.cr = m.cg = m.cb = 1;
+               m.ca = currentrenderentity->alpha;
+               for (i = 0, sv = svert, v = s->mesh.vertex;i < m.numverts;i++, sv++, v++)
+                       softwaretransform(v->v, sv->v);
+       }
+       R_Mesh_Draw(&m);
+}
+
 static void RSurfShader_Wall_Pass_Light(msurface_t *s)
 {
        int                             i;
 static void RSurfShader_Wall_Pass_Light(msurface_t *s)
 {
        int                             i;
@@ -1205,6 +1265,22 @@ static void RSurfShader_Wall_Pass_Fog(msurface_t *s)
        R_Mesh_Draw(&m);
 }
 
        R_Mesh_Draw(&m);
 }
 
+static int RSurfShader_Wall_Fullbright(int stage, msurface_t *s)
+{
+       switch(stage)
+       {
+       case 0:
+               RSurfShader_Wall_Pass_BaseFullbright(s);
+               return false;
+       case 1:
+               if (s->currenttexture->glowtexture)
+                       RSurfShader_Wall_Pass_Glow(s);
+               return false;
+       default:
+               return true;
+       }
+}
+
 static int RSurfShader_Wall_Vertex(int stage, msurface_t *s)
 {
        switch(stage)
 static int RSurfShader_Wall_Vertex(int stage, msurface_t *s)
 {
        switch(stage)
@@ -1673,14 +1749,16 @@ loc1:
 
 Cshader_t Cshader_wall_vertex = {{NULL, RSurfShader_Wall_Vertex, RSurfShader_Wall_Fog}, NULL};
 Cshader_t Cshader_wall_lightmap = {{NULL, RSurfShader_Wall_Lightmap, RSurfShader_Wall_Fog}, NULL};
 
 Cshader_t Cshader_wall_vertex = {{NULL, RSurfShader_Wall_Vertex, RSurfShader_Wall_Fog}, NULL};
 Cshader_t Cshader_wall_lightmap = {{NULL, RSurfShader_Wall_Lightmap, RSurfShader_Wall_Fog}, NULL};
+Cshader_t Cshader_wall_fullbright = {{NULL, RSurfShader_Wall_Fullbright, RSurfShader_Wall_Fog}, NULL};
 Cshader_t Cshader_water = {{NULL, RSurfShader_Water, NULL}, NULL};
 Cshader_t Cshader_sky = {{RSurfShader_Sky, NULL, NULL}, NULL};
 
 Cshader_t Cshader_water = {{NULL, RSurfShader_Water, NULL}, NULL};
 Cshader_t Cshader_sky = {{RSurfShader_Sky, NULL, NULL}, NULL};
 
-int Cshader_count = 4;
-Cshader_t *Cshaders[4] =
+int Cshader_count = 5;
+Cshader_t *Cshaders[5] =
 {
        &Cshader_wall_vertex,
        &Cshader_wall_lightmap,
 {
        &Cshader_wall_vertex,
        &Cshader_wall_lightmap,
+       &Cshader_wall_fullbright,
        &Cshader_water,
        &Cshader_sky
 };
        &Cshader_water,
        &Cshader_sky
 };
index 54324fabacbed2f224ccb97efaf3a41633def2f4..63880a90e3a13f1062651791eef5da0dfb5b99e4 100644 (file)
@@ -831,9 +831,6 @@ static void CalcSurfaceExtents (msurface_t *s)
 
                s->texturemins[i] = bmins[i] * 16;
                s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
 
                s->texturemins[i] = bmins[i] * 16;
                s->extents[i] = (bmaxs[i] - bmins[i]) * 16;
-//             if ( !(tex->flags & TEX_SPECIAL) && s->extents[i] > 512)
-               if ((tex->flags & TEX_SPECIAL) == 0 && (s->extents[i]+1) > (256*16))
-                       Host_Error ("Bad surface extents");
        }
 }
 
        }
 }
 
@@ -1121,6 +1118,39 @@ void Mod_GenerateLightmappedMesh (msurface_t *surf)
        }
 }
 
        }
 }
 
+void Mod_GenerateVertexMesh (msurface_t *surf)
+{
+       int                             i, *index;
+       float                   *in;
+       surfvertex_t    *out;
+       surfmesh_t              *mesh;
+
+       surf->lightmaptexturestride = 0;
+       surf->lightmaptexture = NULL;
+
+       mesh = &surf->mesh;
+       mesh->numverts = surf->poly_numverts;
+       mesh->numtriangles = surf->poly_numverts - 2;
+       mesh->index = Mem_Alloc(loadmodel->mempool, mesh->numtriangles * sizeof(int[3]) + mesh->numverts * sizeof(surfvertex_t));
+       mesh->vertex = (surfvertex_t *)((long) mesh->index + mesh->numtriangles * sizeof(int[3]));
+       memset(mesh->vertex, 0, mesh->numverts * sizeof(surfvertex_t));
+
+       index = mesh->index;
+       for (i = 0;i < mesh->numtriangles;i++)
+       {
+               *index++ = 0;
+               *index++ = i + 1;
+               *index++ = i + 2;
+       }
+
+       for (i = 0, in = surf->poly_verts, out = mesh->vertex;i < mesh->numverts;i++, in += 3, out++)
+       {
+               VectorCopy (in, out->v);
+               out->st[0] = (DotProduct (out->v, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3]) / surf->texinfo->texture->width;
+               out->st[1] = (DotProduct (out->v, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3]) / surf->texinfo->texture->height;
+       }
+}
+
 void Mod_GenerateSurfacePolygon (msurface_t *surf)
 {
        float           *vert;
 void Mod_GenerateSurfacePolygon (msurface_t *surf)
 {
        float           *vert;
@@ -1210,6 +1240,7 @@ static void Mod_LoadFaces (lump_t *l)
                if (out->texinfo->texture->flags & SURF_DRAWSKY)
                {
                        out->shader = &Cshader_sky;
                if (out->texinfo->texture->flags & SURF_DRAWSKY)
                {
                        out->shader = &Cshader_sky;
+                       out->samples = NULL;
                        Mod_GenerateWarpMesh (out);
                        continue;
                }
                        Mod_GenerateWarpMesh (out);
                        continue;
                }
@@ -1224,6 +1255,7 @@ static void Mod_LoadFaces (lump_t *l)
                                out->texturemins[i] = -8192*1024;
                        }
                        */
                                out->texturemins[i] = -8192*1024;
                        }
                        */
+                       out->samples = NULL;
                        Mod_GenerateWarpMesh (out);
                        continue;
                }
                        Mod_GenerateWarpMesh (out);
                        continue;
                }
@@ -1234,8 +1266,16 @@ static void Mod_LoadFaces (lump_t *l)
                {
                        // qbsp couldn't find the texture for this surface, but it was either turb or sky...  assume turb
                        out->shader = &Cshader_water;
                {
                        // qbsp couldn't find the texture for this surface, but it was either turb or sky...  assume turb
                        out->shader = &Cshader_water;
+                       out->samples = NULL;
                        Mod_GenerateWarpMesh (out);
                }
                        Mod_GenerateWarpMesh (out);
                }
+               else if ((out->extents[0]+1) > (256*16) || (out->extents[1]+1) > (256*16))
+               {
+                       Con_Printf ("Bad surface extents, converting to fullbright polygon");
+                       out->shader = &Cshader_wall_fullbright;
+                       out->samples = NULL;
+                       Mod_GenerateVertexMesh(out);
+               }
                else if (out->extents[0] < r_vertexsurfacesthreshold.integer && out->extents[1] < r_vertexsurfacesthreshold.integer)
                {
                        out->shader = &Cshader_wall_vertex;
                else if (out->extents[0] < r_vertexsurfacesthreshold.integer && out->extents[1] < r_vertexsurfacesthreshold.integer)
                {
                        out->shader = &Cshader_wall_vertex;
index c172a07d00ebc4fadf48d4a0cba1c0443e580d5e..fc79e4c0c6b3bd0b5188549b09a431b2c8cf5f80 100644 (file)
@@ -197,6 +197,7 @@ Cshader_t;
 
 extern Cshader_t Cshader_wall_vertex;
 extern Cshader_t Cshader_wall_lightmap;
 
 extern Cshader_t Cshader_wall_vertex;
 extern Cshader_t Cshader_wall_lightmap;
+extern Cshader_t Cshader_wall_fullbright;
 extern Cshader_t Cshader_water;
 extern Cshader_t Cshader_sky;
 
 extern Cshader_t Cshader_water;
 extern Cshader_t Cshader_sky;