]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added backface culling optimization to cl_decals_newsystem, this helps
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 Apr 2011 07:51:52 +0000 (07:51 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 Apr 2011 07:51:52 +0000 (07:51 +0000)
in many cases

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11023 d7cf8633-e32d-0410-b094-e92efae38249

client.h
gl_rmain.c

index 909a5e225d6c05142d8da0764a11d60aa1c38d3c..af4134347343ac1a33145f132ab8c4ca4fd4758e 100644 (file)
--- a/client.h
+++ b/client.h
@@ -35,6 +35,7 @@ typedef struct tridecal_s
        float                   texcoord2f[3][2];
        float                   vertex3f[3][3];
        float                   color4f[3][4];
+       float                   plane[4]; // backface culling
        // how long this decal has lived so far (the actual fade begins at cl_decals_time)
        float                   lived;
        // if >= 0 this indicates the decal should follow an animated triangle
index 0fbb9ad729a7da8cf483b9b230d73f65461cadae..758673f6daa1bcdc53d6f49ecc4e9b9c43d3c715 100644 (file)
@@ -10404,6 +10404,9 @@ static void R_DecalSystem_SpawnTriangle(decalsystem_t *decalsystem, const float
        decal->texcoord2f[1][1] = t1[1];
        decal->texcoord2f[2][0] = t2[0];
        decal->texcoord2f[2][1] = t2[1];
+       TriangleNormal(v0, v1, v2, decal->plane);
+       VectorNormalize(decal->plane);
+       decal->plane[3] = DotProduct(v0, decal->plane);
 }
 
 extern cvar_t cl_decals_bias;
@@ -10857,6 +10860,10 @@ static void R_DrawModelDecals_Entity(entity_render_t *ent)
                if (surfacevisible && !surfacevisible[decal->surfaceindex])
                        continue;
 
+               // skip backfaces
+               if (decal->triangleindex < 0 && DotProduct(r_refdef.view.origin, decal->plane) < decal->plane[3])
+                       continue;
+
                // update color values for fading decals
                if (decal->lived >= cl_decals_time.value)
                        alpha = 1 - faderate * (decal->lived - cl_decals_time.value);