From 59e3b3ad8006957578534b8d3536f4b695609af1 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 21 Sep 2003 03:34:58 +0000 Subject: [PATCH] now supports skyboxes in q3bsp (note: must use the "sky" key in worldspawn to set the skybox basename like in q2, and it identifies sky shaders by names beginning with "textures/skies/"), and added a little error checking to Mod_Q1BSP_LoadLeafs, and added a couple todo items git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3490 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rsurf.c | 44 +++++++++++++++++++++++++++++++++++++++++++- model_brush.c | 18 +++++++++++++++--- model_shared.h | 1 + r_sky.c | 12 ++++++------ todo | 2 ++ 5 files changed, 67 insertions(+), 10 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index 38d17b11..161344ab 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1946,8 +1946,50 @@ void R_DrawCollisionBrush(colbrushf_t *brush) void R_Q3BSP_DrawFace(entity_render_t *ent, q3mface_t *face) { rmeshstate_t m; - if ((face->texture->renderflags & Q3MTEXTURERENDERFLAGS_NODRAW) || !face->numtriangles) + if (!face->numtriangles) return; + if (face->texture->renderflags) + { + if (face->texture->renderflags & Q3MTEXTURERENDERFLAGS_SKY) + { + if (skyrendernow) + { + skyrendernow = false; + if (skyrendermasked) + R_Sky(); + } + + R_Mesh_Matrix(&ent->matrix); + + GL_Color(fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, 1); + if (skyrendermasked) + { + // depth-only (masking) + qglColorMask(0,0,0,0); + // just to make sure that braindead drivers don't draw anything + // despite that colormask... + GL_BlendFunc(GL_ZERO, GL_ONE); + } + else + { + // fog sky + GL_BlendFunc(GL_ONE, GL_ZERO); + } + GL_DepthMask(true); + GL_DepthTest(true); + + memset(&m, 0, sizeof(m)); + R_Mesh_State_Texture(&m); + + GL_VertexPointer(face->data_vertex3f); + R_Mesh_Draw(face->numvertices, face->numtriangles, face->data_element3i); + qglColorMask(1,1,1,1); + return; + } + if (face->texture->renderflags & Q3MTEXTURERENDERFLAGS_NODRAW) + return; + } + R_Mesh_Matrix(&ent->matrix); face->visframe = r_framecount; memset(&m, 0, sizeof(m)); GL_BlendFunc(GL_ONE, GL_ZERO); diff --git a/model_brush.c b/model_brush.c index 2c577105..1fb281eb 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1833,15 +1833,25 @@ static void Mod_Q1BSP_LoadLeafs(lump_t *l) out->firstmarksurface = loadmodel->brushq1.marksurfaces + LittleShort(in->firstmarksurface); out->nummarksurfaces = LittleShort(in->nummarksurfaces); + if (out->firstmarksurface < 0 || LittleShort(in->firstmarksurface) + out->nummarksurfaces > loadmodel->brushq1.nummarksurfaces) + { + Con_Printf("Mod_Q1BSP_LoadLeafs: invalid marksurface range %i:%i outside range %i:%i\n", out->firstmarksurface, out->firstmarksurface + out->nummarksurfaces, 0, loadmodel->brushq1.nummarksurfaces); + out->firstmarksurface = NULL; + out->nummarksurfaces = 0; + } out->pvsdata = pvs; + memset(out->pvsdata, 0xFF, pvschainbytes); pvs += pvschainbytes; p = LittleLong(in->visofs); if (p >= 0) - Mod_Q1BSP_DecompressVis(loadmodel->brushq1.data_compressedpvs + p, loadmodel->brushq1.data_compressedpvs + loadmodel->brushq1.num_compressedpvs, out->pvsdata, out->pvsdata + pvschainbytes); - else - memset(out->pvsdata, 0xFF, pvschainbytes); + { + if (p >= loadmodel->brushq1.num_compressedpvs) + Con_Printf("Mod_Q1BSP_LoadLeafs: invalid visofs\n"); + else + Mod_Q1BSP_DecompressVis(loadmodel->brushq1.data_compressedpvs + p, loadmodel->brushq1.data_compressedpvs + loadmodel->brushq1.num_compressedpvs, out->pvsdata, out->pvsdata + pvschainbytes); + } for (j = 0;j < 4;j++) out->ambient_sound_level[j] = in->ambient_level[j]; @@ -3322,6 +3332,8 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) out->renderflags = 0; if (!strcmp(out->name, "caulk") || !strcmp(out->name, "common/caulk") || !strcmp(out->name, "textures/common/caulk")) out->renderflags |= Q3MTEXTURERENDERFLAGS_NODRAW; + if (!strncmp(out->name, "textures/skies/", 15)) + out->renderflags |= Q3MTEXTURERENDERFLAGS_SKY; out->number = i; Mod_LoadSkinFrame(&out->skin, out->name, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE, false, true, true); diff --git a/model_shared.h b/model_shared.h index 7c1f5ec8..5802d2c1 100644 --- a/model_shared.h +++ b/model_shared.h @@ -269,6 +269,7 @@ model_brushq2_t; */ #define Q3MTEXTURERENDERFLAGS_NODRAW 1 +#define Q3MTEXTURERENDERFLAGS_SKY 2 typedef struct q3mtexture_s { diff --git a/r_sky.c b/r_sky.c index 41f98763..ae126cf6 100644 --- a/r_sky.c +++ b/r_sky.c @@ -186,18 +186,18 @@ float skyboxtexcoord2f[6*4*2] = int skyboxelements[6*2*3] = { - // skyside[0] - 8, 9, 10, - 8, 10, 11, + // skyside[3] + 0, 1, 2, + 0, 2, 3, // skyside[1] 4, 5, 6, 4, 6, 7, + // skyside[0] + 8, 9, 10, + 8, 10, 11, // skyside[2] 12, 13, 14, 12, 14, 15, - // skyside[3] - 0, 1, 2, - 0, 2, 3, // skyside[4] 16, 17, 18, 16, 18, 19, diff --git a/todo b/todo index 601e4d1e..aa9e3533 100644 --- a/todo +++ b/todo @@ -12,6 +12,8 @@ -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv) -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv) -n dpmod: make grapple off-hand (joe hill) +0 darkplaces: server should send sv_gravity to client somehow (Vermeulen) +0 darkplaces: server should send slowmo to client somehow (Vermeulen) 0 darkplaces: make a getattachmentvectors qc builtin (Supajoe) 0 darkplaces: add _reflect textures which filter use of skybox as a cubemap reflection (FrikaC) 0 darkplaces: ability to disable fopen builtin access to read /, read data/, write data/, or disable fopen builtin entirely -- 2.39.2