]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
modified Mod_LoadSkinFrame to not attempt to generate a fogging mask if
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 23 Apr 2007 19:39:18 +0000 (19:39 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 23 Apr 2007 19:39:18 +0000 (19:39 +0000)
not given the TEXF_ALPHA flag (in which case the fog mask would not be
used anyway)

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

model_shared.c

index 090c93d16ec70fb6d89cea238329ede09035b6fd..a796f3f709fdebfe149cd7ed5d3fb78b30e2eeb9 100644 (file)
@@ -1070,22 +1070,25 @@ int Mod_LoadSkinFrame(skinframe_t *skinframe, const char *basename, int texturef
        basepixels_height = image_height;
        skinframe->base = R_LoadTexture2D (loadmodel->texturepool, basename, basepixels_width, basepixels_height, basepixels, TEXTYPE_RGBA, textureflags, NULL);
 
-       for (j = 3;j < basepixels_width * basepixels_height * 4;j += 4)
-               if (basepixels[j] < 255)
-                       break;
-       if (j < basepixels_width * basepixels_height * 4)
+       if (textureflags & TEXF_ALPHA)
        {
-               // has transparent pixels
-               pixels = (unsigned char *)Mem_Alloc(loadmodel->mempool, image_width * image_height * 4);
-               for (j = 0;j < image_width * image_height * 4;j += 4)
+               for (j = 3;j < basepixels_width * basepixels_height * 4;j += 4)
+                       if (basepixels[j] < 255)
+                               break;
+               if (j < basepixels_width * basepixels_height * 4)
                {
-                       pixels[j+0] = 255;
-                       pixels[j+1] = 255;
-                       pixels[j+2] = 255;
-                       pixels[j+3] = basepixels[j+3];
+                       // has transparent pixels
+                       pixels = (unsigned char *)Mem_Alloc(loadmodel->mempool, image_width * image_height * 4);
+                       for (j = 0;j < image_width * image_height * 4;j += 4)
+                       {
+                               pixels[j+0] = 255;
+                               pixels[j+1] = 255;
+                               pixels[j+2] = 255;
+                               pixels[j+3] = basepixels[j+3];
+                       }
+                       skinframe->fog = R_LoadTexture2D (loadmodel->texturepool, va("%s_mask", basename), image_width, image_height, pixels, TEXTYPE_RGBA, textureflags, NULL);
+                       Mem_Free(pixels);
                }
-               skinframe->fog = R_LoadTexture2D (loadmodel->texturepool, va("%s_mask", basename), image_width, image_height, pixels, TEXTYPE_RGBA, textureflags, NULL);
-               Mem_Free(pixels);
        }
 
        // _luma is supported for tenebrae compatibility