[prboom+] 02/03: Imported Upstream version 2.5.1.4~svn4433+dfsg1

Fabian Greffrath fabian at moszumanska.debian.org
Sun Sep 13 11:12:40 UTC 2015


This is an automated email from the git hooks/post-receive script.

fabian pushed a commit to branch master
in repository prboom+.

commit f79467edfeef5c5f0eba524b42f937dcf2164325
Author: Fabian Greffrath <fabian+debian at greffrath.com>
Date:   Sun Sep 13 13:12:22 2015 +0200

    Imported Upstream version 2.5.1.4~svn4433+dfsg1
---
 src/p_setup.c |  10 ++++
 src/r_patch.c | 186 +++++++++++++++++++++++++++-------------------------------
 2 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/src/p_setup.c b/src/p_setup.c
index 8d859ad..7e3e12f 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -2267,6 +2267,16 @@ static void P_RemoveSlimeTrails(void)         // killough 10/98
         int x0 = v->x, y0 = v->y, x1 = l->v1->x, y1 = l->v1->y;
         v->px = (int)((dx2 * x0 + dy2 * x1 + dxy * (y0 - y1)) / s);
         v->py = (int)((dy2 * y0 + dx2 * y1 + dxy * (x0 - x1)) / s);
+        
+        // [crispy] wait a minute... moved more than 8 map units?
+        // maybe that's a linguortal then, back to the original coordinates
+        // http://www.doomworld.com/vb/doom-editing/74354-stupid-bsp-tricks/
+        if (!apply_for_real_vertexes && (D_abs(v->px - v->x) > 8*FRACUNIT || D_abs(v->py - v->y) > 8*FRACUNIT))
+        {
+          v->px = v->x;
+          v->py = v->y;
+        }
+
         if (apply_for_real_vertexes)
         {
           v->x = v->px;
diff --git a/src/r_patch.c b/src/r_patch.c
index 5724a8c..b04992c 100644
--- a/src/r_patch.c
+++ b/src/r_patch.c
@@ -215,6 +215,92 @@ static int getColumnEdgeSlope(const column_t *prevcolumn, const column_t *nextco
   return 0;
 }
 
+//---------------------------------------------------------------------------
+static void FillEmptySpace(rpatch_t *patch)
+{
+  int x, y, w, h, numpix, pass, transparent, has_holes;
+  byte *orig, *copy, *src, *dest, *prev, *next;
+
+  // loop over patch looking for transparent pixels next to solid ones
+  // copy solid pixels into the spaces, dilating the patch outwards
+  // repeat either a fixed number of times or until all space is filled
+  // this eliminates artifacts surrounding weapon sprites (e.g. chainsaw)
+
+  w = patch->width;
+  h = patch->height;
+  numpix = w * h;
+
+  // alternate between two buffers to avoid "overlapping memcpy"-like symptoms
+  orig = patch->pixels;
+  copy = malloc(numpix);
+
+  for (pass = 0; pass < 8; pass++) // arbitrarily chosen limit (must be even)
+  {
+    // copy src to dest, then switch them on next pass
+    // (this requires an even number of passes)
+    src  = ((pass & 1) == 0) ? orig : copy;
+    dest = ((pass & 1) == 0) ? copy : orig;
+
+    // previous and next columns adjacent to current column x
+    // these pointers must not be dereferenced without appropriate checks
+    prev = src - h; // only valid when x > 0
+    next = src + h; // only valid when x < w-1
+
+    has_holes = 0; // if the patch has any holes at all
+    transparent = 0; // number of pixels this pass did not handle
+
+    // detect transparent pixels on edges, copy solid colour into the space
+    // the order of directions (up,down,left,right) is arbitrarily chosen
+    for (x = 0; x < w; x++)
+    {
+      for (y = 0; y < h; y++)
+      {
+        if (*src == 0xff) has_holes = 1;
+
+        if (*src != 0xff) // already a solid pixel, just copy it over
+          *dest = *src;
+        else if (y > 0 && *(src-1) != 0xff) // solid pixel above
+          *dest = *(src - 1);
+        else if (y < h-1 && *(src+1) != 0xff) // solid pixel below
+          *dest = *(src + 1);
+        else if (x > 0 && *prev != 0xff) // solid pixel to left
+          *dest = *prev;
+        else if (x < w-1 && *next != 0xff) // solid pixel to right
+          *dest = *next;
+        else // transparent pixel with no adjacent solid pixels
+          *dest = *src, transparent++; // count unhandled pixels
+
+        prev++, src++, next++, dest++;
+      }
+    }
+
+    if (transparent == 0) // no more transparent pixels to fill
+    {
+      if ((pass & 1) == 0) // dest was copy, src was orig: orig needs update
+        memcpy(orig, copy, numpix);
+      break;
+    }
+    else if (transparent == numpix)
+      break; // avoid infinite loop on entirely transparent patches (STBR127)
+  }
+
+  free(copy);
+
+  // copy top row of patch into any space at bottom, and vice versa
+  // a hack to fix erroneous row of pixels at top of firing chaingun
+
+  for (x = 0, src = orig, dest = src + h-1; x < w; x++, src += h, dest += h)
+  {
+    if (*src != 0xff && *dest == 0xff) // bottom transparent, top solid
+      *dest = *src;
+    else if (*src == 0xff && *dest != 0xff) // top transparent, bottom solid
+      *src = *dest;
+  }
+
+  if (has_holes)
+    patch->flags |= PATCH_HASHOLES;
+}
+
 //==========================================================================
 //
 // Checks if the lump can be a Doom patch
@@ -429,55 +515,7 @@ static void createPatch(int id) {
     }
   }
 
-  if (1 || (patch->flags&PATCH_ISNOTTILEABLE)) {
-    const rcolumn_t *column, *prevColumn;
-
-    // copy the patch image down and to the right where there are
-    // holes to eliminate the black halo from bilinear filtering
-    for (x=0; x<patch->width; x++) {
-      //oldColumn = (const column_t *)((const byte *)oldPatch + oldPatch->columnofs[x]);
-
-      column = R_GetPatchColumnClamped(patch, x);
-      prevColumn = R_GetPatchColumnClamped(patch, x-1);
-
-      if (column->pixels[0] == 0xff) {
-        // e6y: marking of all patches with holes
-        patch->flags |= PATCH_HASHOLES;
-
-        // force the first pixel (which is a hole), to use
-        // the color from the next solid spot in the column
-        for (y=0; y<patch->height; y++) {
-          if (column->pixels[y] != 0xff) {
-            column->pixels[0] = column->pixels[y];
-            break;
-          }
-        }
-      }
-
-      // copy from above or to the left
-      for (y=1; y<patch->height; y++) {
-        //if (getIsSolidAtSpot(oldColumn, y)) continue;
-        if (column->pixels[y] != 0xff) continue;
-
-        // this pixel is a hole
-
-        // e6y: marking of all patches with holes
-        patch->flags |= PATCH_HASHOLES;
-
-        if (x && prevColumn->pixels[y-1] != 0xff) {
-          // copy the color from the left
-          column->pixels[y] = prevColumn->pixels[y];
-        }
-        else {
-          // copy the color from above
-          column->pixels[y] = column->pixels[y-1];
-        }
-      }
-    }
-
-    // verify that the patch truly is non-rectangular since
-    // this determines tiling later on
-  }
+  FillEmptySpace(patch);
 
   W_UnlockLumpNum(patchNum);
   free(numPostsInColumn);
@@ -762,55 +800,7 @@ static void createTextureCompositePatch(int id) {
     }
   }
 
-  if (1 || (composite_patch->flags&PATCH_ISNOTTILEABLE)) {
-    const rcolumn_t *column, *prevColumn;
-
-    // copy the patch image down and to the right where there are
-    // holes to eliminate the black halo from bilinear filtering
-    for (x=0; x<composite_patch->width; x++) {
-      //oldColumn = (const column_t *)((const byte *)oldPatch + oldPatch->columnofs[x]);
-
-      column = R_GetPatchColumnClamped(composite_patch, x);
-      prevColumn = R_GetPatchColumnClamped(composite_patch, x-1);
-
-      if (column->pixels[0] == 0xff) {
-        // e6y: marking of all patches with holes
-        composite_patch->flags |= PATCH_HASHOLES;
-
-        // force the first pixel (which is a hole), to use
-        // the color from the next solid spot in the column
-        for (y=0; y<composite_patch->height; y++) {
-          if (column->pixels[y] != 0xff) {
-            column->pixels[0] = column->pixels[y];
-            break;
-          }
-        }
-      }
-
-      // copy from above or to the left
-      for (y=1; y<composite_patch->height; y++) {
-        //if (getIsSolidAtSpot(oldColumn, y)) continue;
-        if (column->pixels[y] != 0xff) continue;
-
-        // this pixel is a hole
-
-        // e6y: marking of all patches with holes
-        composite_patch->flags |= PATCH_HASHOLES;
-
-        if (x && prevColumn->pixels[y-1] != 0xff) {
-          // copy the color from the left
-          column->pixels[y] = prevColumn->pixels[y];
-        }
-        else {
-          // copy the color from above
-          column->pixels[y] = column->pixels[y-1];
-        }
-      }
-    }
-
-    // verify that the patch truly is non-rectangular since
-    // this determines tiling later on
-  }
+  FillEmptySpace(composite_patch);
 
   free(countsInColumn);
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/prboom+.git



More information about the Pkg-games-commits mailing list