foxygit / doom Log in
commit bdd800ded2c0e2df1b15372135b9cfd5901f6ecd
Author:     Samuel Villareal <svkaiser@gmail.com>
AuthorDate: Tue Sep 7 00:11:51 2010 +0000
Commit:     Samuel Villareal <svkaiser@gmail.com>
CommitDate: Tue Sep 7 00:11:51 2010 +0000

    + Translucent sprites - initial implementation

    Subversion-branch: /branches/strife-branch
    Subversion-revision: 2029
---
 src/strife/r_draw.c   | 151 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/strife/r_draw.h   |   9 ++-
 src/strife/r_main.c   |  10 ++--
 src/strife/r_things.c |  33 +++++++++--
 4 files changed, 188 insertions(+), 15 deletions(-)

diff --git a/src/strife/r_draw.c b/src/strife/r_draw.c
index b8adbf9b..0e887b99 100644
--- a/src/strife/r_draw.c
+++ b/src/strife/r_draw.c
@@ -415,9 +415,109 @@ void R_DrawFuzzColumnLow (void)

 	frac += fracstep;
     } while (count--);
-}
+}
+
+//
+// R_DrawTLColumn
+//
+// villsa [STRIFE] new function
+// Replacement for R_DrawFuzzColumn
+//
+void R_DrawTLColumn(void)
+{
+     int			count;
+    byte*		dest;
+    fixed_t		frac;
+    fixed_t		fracstep;
+
+    // Adjust borders. Low...
+    if (!dc_yl)
+	dc_yl = 1;
+
+    // .. and high.
+    if (dc_yh == viewheight-1)
+	dc_yh = viewheight - 2;
+
+    count = dc_yh - dc_yl;
+
+    // Zero length.
+    if (count < 0)
+	return;
+
+#ifdef RANGECHECK
+    if ((unsigned)dc_x >= SCREENWIDTH
+	|| dc_yl < 0 || dc_yh >= SCREENHEIGHT)
+    {
+	I_Error ("R_DrawFuzzColumn: %i to %i at %i",
+		 dc_yl, dc_yh, dc_x);
+    }
+#endif
+
+    dest = ylookup[dc_yl] + columnofs[dc_x];
+
+    // Looks familiar.
+    fracstep = dc_iscale;
+    frac = dc_texturemid + (dc_yl-centery)*fracstep;
+
+    do
+    {
+        *dest = xlatab[*dest+
+            (dc_colormap[dc_source[(frac>>FRACBITS)&127]]<<8)];
+        dest += SCREENWIDTH;
+        frac += fracstep;
+    } while(count--);
+}

-
+
+//
+// R_DrawMVisTLColumn
+//
+// villsa [STRIFE] new function
+//
+void R_DrawMVisTLColumn(void)
+{
+     int			count;
+    byte*		dest;
+    fixed_t		frac;
+    fixed_t		fracstep;
+
+    // Adjust borders. Low...
+    if (!dc_yl)
+	dc_yl = 1;
+
+    // .. and high.
+    if (dc_yh == viewheight-1)
+	dc_yh = viewheight - 2;
+
+    count = dc_yh - dc_yl;
+
+    // Zero length.
+    if (count < 0)
+	return;
+
+#ifdef RANGECHECK
+    if ((unsigned)dc_x >= SCREENWIDTH
+	|| dc_yl < 0 || dc_yh >= SCREENHEIGHT)
+    {
+	I_Error ("R_DrawFuzzColumn: %i to %i at %i",
+		 dc_yl, dc_yh, dc_x);
+    }
+#endif
+
+    dest = ylookup[dc_yl] + columnofs[dc_x];
+
+    // Looks familiar.
+    fracstep = dc_iscale;
+    frac = dc_texturemid + (dc_yl-centery)*fracstep;
+
+    do
+    {
+        *dest = xlatab[((*dest)<<8)
+            + dc_colormap[dc_source[(frac>>FRACBITS)&127]]];
+        dest += SCREENWIDTH;
+        frac += fracstep;
+    } while(count--);
+}



@@ -527,7 +627,52 @@ void R_DrawTranslatedColumnLow (void)

 	frac += fracstep;
     } while (count--);
-}
+}
+
+//
+// R_DrawTRTLColumn
+//
+// villsa [STRIFE] new function
+//
+void R_DrawTRTLColumn(void)
+{
+    int			count;
+    byte*		dest;
+    fixed_t		frac;
+    fixed_t		fracstep;
+
+    count = dc_yh - dc_yl;
+    if (count < 0)
+	return;
+
+#ifdef RANGECHECK
+    if ((unsigned)dc_x >= SCREENWIDTH
+	|| dc_yl < 0
+	|| dc_yh >= SCREENHEIGHT)
+    {
+	I_Error ( "R_DrawColumn: %i to %i at %i",
+		  dc_yl, dc_yh, dc_x);
+    }
+
+#endif
+
+
+    dest = ylookup[dc_yl] + columnofs[dc_x];
+
+    // Looks familiar.
+    fracstep = dc_iscale;
+    frac = dc_texturemid + (dc_yl-centery)*fracstep;
+
+    // Here we do an additional index re-mapping.
+    do
+    {
+        *dest = xlatab[((*dest)<<8)
+            + dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]];
+	dest += SCREENWIDTH;
+
+	frac += fracstep;
+    } while (count--);
+}


 // haleyjd 08/26/10: [STRIFE] - Rogue's translucency lookup table
diff --git a/src/strife/r_draw.h b/src/strife/r_draw.h
index 16533acf..aaa64711 100644
--- a/src/strife/r_draw.h
+++ b/src/strife/r_draw.h
@@ -49,8 +49,8 @@ void 	R_DrawColumn (void);
 void 	R_DrawColumnLow (void);

 // The Spectre/Invisibility effect.
-void 	R_DrawFuzzColumn (void);
-void 	R_DrawFuzzColumnLow (void);
+//void 	R_DrawFuzzColumn (void);
+//void 	R_DrawFuzzColumnLow (void);

 // Draw with color translation tables,
 //  for player sprite rendering,
@@ -58,6 +58,11 @@ void 	R_DrawFuzzColumnLow (void);
 void	R_DrawTranslatedColumn (void);
 void	R_DrawTranslatedColumnLow (void);

+// villsa [STRIFE] - transclucent rendering
+void    R_DrawTLColumn (void);
+void    R_DrawMVisTLColumn (void);
+void    R_DrawTRTLColumn (void);
+
 void
 R_VideoErase
 ( unsigned	ofs,
diff --git a/src/strife/r_main.c b/src/strife/r_main.c
index bc902e4a..d9f0672a 100644
--- a/src/strife/r_main.c
+++ b/src/strife/r_main.c
@@ -709,20 +709,21 @@ void R_ExecuteSetViewSize (void)
     centeryfrac = centery<<FRACBITS;
     projection = centerxfrac;

-    if (!detailshift)
+    //if (!detailshift) // villsa [STRIFE]
     {
 	colfunc = basecolfunc = R_DrawColumn;
-	fuzzcolfunc = R_DrawFuzzColumn;
+	fuzzcolfunc = R_DrawTLColumn;   // villsa [STRIFE]
 	transcolfunc = R_DrawTranslatedColumn;
 	spanfunc = R_DrawSpan;
     }
-    else
+    // villsa [STRIFE] unused detail stuff
+    /*else
     {
 	colfunc = basecolfunc = R_DrawColumnLow;
 	fuzzcolfunc = R_DrawFuzzColumnLow;
 	transcolfunc = R_DrawTranslatedColumnLow;
 	spanfunc = R_DrawSpanLow;
-    }
+    }*/

     R_InitBuffer (scaledviewwidth, viewheight);

@@ -930,3 +931,4 @@ void R_RenderPlayerView (player_t* player)
     // Check for new console commands.
     NetUpdate ();
 }
+
diff --git a/src/strife/r_things.c b/src/strife/r_things.c
index a13f355b..112e4214 100644
--- a/src/strife/r_things.c
+++ b/src/strife/r_things.c
@@ -413,23 +413,43 @@ R_DrawVisSprite
     fixed_t		frac;
     patch_t*		patch;
     int                 clip;   // villsa [STRIFE]
+    int                 translation;    // villsa [STRIFE]


     patch = W_CacheLumpNum (vis->patch+firstspritelump, PU_CACHE);

     dc_colormap = vis->colormap;
+
+    // villsa [STRIFE]
+    translation = vis->mobjflags & (MF_COLORSWAP1|MF_COLORSWAP2|MF_COLORSWAP3);

-    if (!dc_colormap)
+    // villsa [STRIFE] unused
+    /*if (!dc_colormap)
     {
 	// NULL colormap = shadow draw
 	colfunc = fuzzcolfunc;
+    }*/
+    // villsa [STRIFE]
+    if(vis->mobjflags & MF_SHADOW)
+    {
+        if(!translation)
+        {
+            if(vis->mobjflags & MF_MVIS)
+                colfunc = R_DrawMVisTLColumn;
+            else
+                colfunc = fuzzcolfunc;
+        }
+        else
+        {
+            colfunc = R_DrawTRTLColumn;
+	    dc_translation = translationtables - 256 + (translation>>20);
+        }
     }
     // villsa [STRIFE] new translation tables
-    else if (vis->mobjflags & (MF_COLORSWAP1|MF_COLORSWAP2|MF_COLORSWAP3))
+    else if (translation)
     {
 	colfunc = transcolfunc;
-	dc_translation = translationtables - 256 +
-	    ((vis->mobjflags & (MF_COLORSWAP1|MF_COLORSWAP2|MF_COLORSWAP3))>>20);
+	dc_translation = translationtables - 256 + (translation>>20);
     }

     dc_iscale = abs(vis->xiscale)>>detailshift;
@@ -602,12 +622,13 @@ void R_ProjectSprite (mobj_t* thing)
     vis->patch = lump;

     // get light level
-    if (thing->flags & MF_SHADOW)
+    // villsa [STRIFE] unused
+    /*if (thing->flags & MF_SHADOW)
     {
 	// shadow draw
 	vis->colormap = NULL;
     }
-    else if (fixedcolormap)
+    else */if (fixedcolormap)
     {
 	// fixed map
 	vis->colormap = fixedcolormap;