fix zfighting on decals in D3D9 (where negative polygon offset isn't possible)
[xonotic/darkplaces.git] / gl_rmain.c
index 40670cd..f89619b 100644 (file)
@@ -13031,6 +13031,7 @@ static void R_DecalSystem_SplatTriangle(decalsystem_t *decalsystem, float r, flo
        int index;
        float v[9][3];
        const float *vertex3f;
+       const float *normal3f;
        int numpoints;
        float points[2][9][3];
        float temp[3];
@@ -13042,11 +13043,12 @@ static void R_DecalSystem_SplatTriangle(decalsystem_t *decalsystem, float r, flo
        e = rsurface.modelelement3i + 3*triangleindex;
 
        vertex3f = rsurface.modelvertex3f;
+       normal3f = rsurface.modelnormal3f;
 
        for (cornerindex = 0;cornerindex < 3;cornerindex++)
        {
                index = 3*e[cornerindex];
-               VectorCopy(vertex3f + index, v[cornerindex]);
+               VectorMA(vertex3f + index, cl_decals_bias.value, normal3f + index, v[cornerindex]);
        }
        // cull backfaces
        //TriangleNormal(v[0], v[1], v[2], normal);
@@ -13151,7 +13153,7 @@ static void R_DecalSystem_SplatEntity(entity_render_t *ent, const vec3_t worldor
                R_DecalSystem_Reset(decalsystem);
        decalsystem->model = model;
 
-       RSurf_ActiveModelEntity(ent, false, false, false);
+       RSurf_ActiveModelEntity(ent, true, false, false);
 
        Matrix4x4_Transform(&rsurface.inversematrix, worldorigin, localorigin);
        Matrix4x4_Transform3x3(&rsurface.inversematrix, worldnormal, localnormal);