]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed -tenebrae support, added glass and mirror rendering and caulk
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 30 Jan 2008 07:18:56 +0000 (07:18 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 30 Jan 2008 07:18:56 +0000 (07:18 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8052 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
image.c
model_brush.c
progdefs.h
progsvm.h
prvm_edict.c
sv_main.c

index 87ceb6567401a48b2431e93c47a6eb160d3d19d4..1df9f4915602beefb0771a9ff958baca3ab06ebd 100644 (file)
@@ -2926,6 +2926,7 @@ static void R_Water_AddWaterPlane(msurface_t *surface)
        vec3_t vert[3];
        vec3_t normal;
        vec3_t center;
+       mplane_t plane;
        r_waterstate_waterplane_t *p;
        // just use the first triangle with a valid normal for any decisions
        VectorClear(normal);
@@ -2939,6 +2940,21 @@ static void R_Water_AddWaterPlane(msurface_t *surface)
                        break;
        }
 
+       VectorCopy(normal, plane.normal);
+       VectorNormalize(plane.normal);
+       plane.dist = DotProduct(vert[0], plane.normal);
+       PlaneClassify(&plane);
+       if (PlaneDiff(r_refdef.view.origin, &plane) < 0)
+       {
+               // skip backfaces (except if nocullface is set)
+               if (!(surface->texture->currentframe->currentmaterialflags & MATERIALFLAG_NOCULLFACE))
+                       return;
+               VectorNegate(plane.normal, plane.normal);
+               plane.dist *= -1;
+               PlaneClassify(&plane);
+       }
+
+
        // find a matching plane if there is one
        for (planeindex = 0, p = r_waterstate.waterplanes;planeindex < r_waterstate.numwaterplanes;planeindex++, p++)
                if (fabs(PlaneDiff(vert[0], &p->plane)) < 1 && fabs(PlaneDiff(vert[1], &p->plane)) < 1 && fabs(PlaneDiff(vert[2], &p->plane)) < 1)
@@ -2951,17 +2967,7 @@ static void R_Water_AddWaterPlane(msurface_t *surface)
        {
                // store the new plane
                r_waterstate.numwaterplanes++;
-               VectorCopy(normal, p->plane.normal);
-               VectorNormalize(p->plane.normal);
-               p->plane.dist = DotProduct(vert[0], p->plane.normal);
-               PlaneClassify(&p->plane);
-               // flip the plane if it does not face the viewer
-               if (PlaneDiff(r_refdef.view.origin, &p->plane) < 0)
-               {
-                       VectorNegate(p->plane.normal, p->plane.normal);
-                       p->plane.dist *= -1;
-                       PlaneClassify(&p->plane);
-               }
+               p->plane = plane;
                // clear materialflags and pvs
                p->materialflags = 0;
                p->pvsvalid = false;
diff --git a/image.c b/image.c
index 2146a64758756dbde6d5dc1ad2170f2c4af1aae2..5ff4076e56a3633a061f43e0ccc1096c0e8ee41b 100644 (file)
--- a/image.c
+++ b/image.c
@@ -703,6 +703,10 @@ imageformat_t imageformats_tenebrae[] =
        {"override/%s.png", PNG_LoadImage_BGRA},
        {"override/%s.jpg", JPEG_LoadImage_BGRA},
        {"override/%s.pcx", LoadPCX_BGRA},
+       {"%s.tga", LoadTGA_BGRA},
+       {"%s.png", PNG_LoadImage_BGRA},
+       {"%s.jpg", JPEG_LoadImage_BGRA},
+       {"%s.pcx", LoadPCX_BGRA},
        {NULL, NULL}
 };
 
index 3278bcd467722a140210bedcbc1ccc06bee19084..12ae4d6feb9784391354336e78bcf211187b07f3 100644 (file)
@@ -1317,6 +1317,9 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
        unsigned char *data, *mtdata;
        const char *s;
        char mapname[MAX_QPATH], name[MAX_QPATH];
+       unsigned char zero[4];
+
+       memset(zero, 0, sizeof(zero));
 
        loadmodel->data_textures = NULL;
 
@@ -1533,14 +1536,29 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l)
                        if (tx->name[0] == '*')
                        {
                                // LordHavoc: some turbulent textures should not be affected by wateralpha
-                               if (strncmp(tx->name,"*lava",5)
-                                && strncmp(tx->name,"*teleport",9)
-                                && strncmp(tx->name,"*rift",5)) // Scourge of Armagon texture
-                                       tx->basematerialflags |= MATERIALFLAG_WATERALPHA | MATERIALFLAG_NOSHADOW | MATERIALFLAG_WATERSHADER;
-                               tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES | MATERIALFLAG_NOSHADOW;
+                               if (!strncmp(tx->name, "*glassmirror", 12)) // Tenebrae
+                               {
+                                       // replace the texture with transparent black
+                                       tx->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_MIPMAP | TEXF_PRECACHE, zero, 1, 1);
+                                       tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_NOSHADOW | MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_REFLECTION;
+                               }
+                               else if (!strncmp(tx->name,"*lava",5)
+                                || !strncmp(tx->name,"*teleport",9)
+                                || !strncmp(tx->name,"*rift",5)) // Scourge of Armagon texture
+                                       tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES | MATERIALFLAG_NOSHADOW;
+                               else
+                                       tx->basematerialflags |= MATERIALFLAG_WATER | MATERIALFLAG_LIGHTBOTHSIDES | MATERIALFLAG_NOSHADOW | MATERIALFLAG_WATERALPHA | MATERIALFLAG_WATERSHADER;
+                       }
+                       else if (!strncmp(tx->name, "mirror", 6)) // Tenebrae
+                       {
+                               // replace the texture with transparent black
+                               tx->skinframes[0] = R_SkinFrame_LoadInternalBGRA(tx->name, TEXF_PRECACHE, zero, 1, 1);
+                               tx->basematerialflags |= MATERIALFLAG_WALL | MATERIALFLAG_REFLECTION;
                        }
                        else if (!strncmp(tx->name, "sky", 3))
                                tx->basematerialflags |= MATERIALFLAG_SKY | MATERIALFLAG_NOSHADOW;
+                       else if (!strcmp(tx->name, "caulk"))
+                               tx->basematerialflags = MATERIALFLAG_NODRAW;
                        else
                                tx->basematerialflags |= MATERIALFLAG_WALL;
                        if (tx->skinframes[0] && tx->skinframes[0]->fog)
index 15db54886c4407396035f207858dc979dad3eaea..7086dbdc459767c2d70a87b8e7d92cd5e8d4cd78 100644 (file)
@@ -164,6 +164,7 @@ typedef struct entvars_s
 } entvars_t;
 
 #define PROGHEADER_CRC 5927
+#define PROGHEADER_CRC_TENEBRAE 32401
 
 #endif
 
index 2033411b00eb1df4cb1eba4d1c16cdc8d68833f4..3a6028b1bd4fc5828a1fd66b478c9741be6334ee 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -354,6 +354,7 @@ typedef struct prvm_prog_s
        int                                     localstack_used;
 
        unsigned short          headercrc; // [INIT]
+       unsigned short          headercrc2; // [INIT] alternate CRC for tenebrae progs.dat
 
        unsigned short          filecrc;
 
index 092f560f74611cfc6c6bbe83c6f20d694a663183..9e85cfc7dac516f735d56f1bc77a29ae73790782 100644 (file)
@@ -1590,8 +1590,8 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required
 
        if (prog->progs->version != PROG_VERSION)
                PRVM_ERROR ("%s: %s has wrong version number (%i should be %i)", PRVM_NAME, filename, prog->progs->version, PROG_VERSION);
-       if (prog->progs->crc != prog->headercrc)
-               PRVM_ERROR ("%s: %s system vars have been modified, progdefs.h is out of date", PRVM_NAME, filename);
+       if (prog->progs->crc != prog->headercrc && prog->progs->crc != prog->headercrc2)
+               PRVM_ERROR ("%s: %s system vars have been modified (CRC of progs.dat systemvars %i != engine %i), progdefs.h is out of date", PRVM_NAME, filename, prog->progs->crc, prog->headercrc);
 
        //prog->functions = (dfunction_t *)((unsigned char *)progs + progs->ofs_functions);
        dfunctions = (dfunction_t *)((unsigned char *)prog->progs + prog->progs->ofs_functions);
index a15f914c96c8ca5dd0aafbec7295dac4d2dc01c0..72a9d326accf207e6c5af911c6a0bfa8bbf72f3c 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -2867,6 +2867,7 @@ static void SV_VM_Setup(void)
        prog->builtins = vm_sv_builtins;
        prog->numbuiltins = vm_sv_numbuiltins;
        prog->headercrc = PROGHEADER_CRC;
+       prog->headercrc2 = PROGHEADER_CRC_TENEBRAE;
        prog->max_edicts = 512;
        if (sv.protocol == PROTOCOL_QUAKE)
                prog->limit_edicts = 640; // before quake mission pack 1 this was 512