diff --git a/docs/rh-log.txt b/docs/rh-log.txt index fbf31009e..a68c420ad 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ -August 9, 2009 (Changes by Graf Zahl) +August 10, 2009 (Changes by Graf Zahl) +- Fixed: The true color texture compositing code did not clip the edges + of multipatch textures used as patches on other multipatch textures. + +August 9, 2009 (Changes by Graf Zahl) - Fixed: A_EntityAttack did not spawn the correct missiles. August 8, 2009 (Changes by Graf Zahl) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index f66aed72c..f837dc0fa 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -333,7 +333,6 @@ bool P_CheckFor3DCeilingHit(AActor * mo) // that the given sector uses to light floors/ceilings/walls according to the 3D floors. // //========================================================================== -#define CenterSpot(sec) (vertex_t*)&(sec)->soundorg[0] void P_Recalculate3DFloors(sector_t * sector) { diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index f5631d8cc..254884c8d 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -2,6 +2,8 @@ #define __SECTORE_H +#define CenterSpot(sec) (vertex_t*)&(sec)->soundorg[0] + //#define _3DFLOORS // 3D floor flags. Most are the same as in Legacy but I added some for EDGE's and Vavoom's features as well. diff --git a/src/r_data.h b/src/r_data.h index acd70284d..65a7f9740 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -49,7 +49,7 @@ public: FWarpTexture (FTexture *source); ~FWarpTexture (); - virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); + virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w=-1, int h=-1, int rotate=0, FCopyInfo *inf = NULL); const BYTE *GetColumn (unsigned int column, const Span **spans_out); const BYTE *GetPixels (); void Unload (); @@ -93,6 +93,8 @@ public: void Unload (); bool CheckModified (); void RenderView (AActor *viewpoint, int fov); + void RenderGLView(AActor *viewpoint, int fov); + void NeedUpdate() { bNeedsUpdate=true; } protected: DSimpleCanvas *Canvas; diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 35ad52f01..52258e8c9 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -182,7 +182,7 @@ protected: void DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL); void DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL); - int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL); bool UseBasePalette(); friend class FTexture; @@ -874,7 +874,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu // //=========================================================================== -int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { FWadLump lump = Wads.OpenLumpNum (SourceLump); @@ -899,8 +899,11 @@ int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo DecompressDXT5 (lump, Format == ID_DXT4, TexBuffer); } + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + // All formats decompress to RGBA. - bmp->CopyPixelDataRGB(x, y, TexBuffer, Width, Height, 4, Width*4, rotate, CF_RGBA, inf); + bmp->CopyPixelDataRGB(x, y, TexBuffer, w, h, 4, Width*4, rotate, CF_RGBA, inf); delete [] TexBuffer; return -1; } diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 7a45e6001..5e41af22f 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -168,7 +168,7 @@ public: const BYTE *GetPixels (); void Unload (); FTextureFormat GetFormat (); - int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL); bool UseBasePalette(); protected: @@ -445,7 +445,7 @@ void FJPEGTexture::MakeTexture () // //=========================================================================== -int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { PalEntry pe[256]; @@ -460,6 +460,9 @@ int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FC cinfo.err->error_exit = JPEG_ErrorExit; jpeg_create_decompress(&cinfo); + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + try { FLumpSourceMgr sourcemgr(&lump, &cinfo); @@ -488,18 +491,18 @@ int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FC switch (cinfo.out_color_space) { case JCS_RGB: - bmp->CopyPixelDataRGB(x, y, buff, cinfo.output_width, cinfo.output_height, + bmp->CopyPixelDataRGB(x, y, buff, w, h, 3, cinfo.output_width * cinfo.output_components, rotate, CF_RGB, inf); break; case JCS_GRAYSCALE: for(int i=0;i<256;i++) pe[i]=PalEntry(255,i,i,i); // default to a gray map - bmp->CopyPixelData(x, y, buff, cinfo.output_width, cinfo.output_height, + bmp->CopyPixelData(x, y, buff, w, h, 1, cinfo.output_width, rotate, pe, inf); break; case JCS_CMYK: - bmp->CopyPixelDataRGB(x, y, buff, cinfo.output_width, cinfo.output_height, + bmp->CopyPixelDataRGB(x, y, buff, w, h, 4, cinfo.output_width * cinfo.output_components, rotate, CF_CMYK, inf); break; diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index c186b63b9..059baca99 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -158,7 +158,7 @@ public: void Unload (); virtual void SetFrontSkyLayer (); - int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL); int GetSourceLump() { return DefinitionLump; } protected: @@ -551,11 +551,14 @@ void FMultiPatchTexture::MakeTexture () // //=========================================================================== -int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { int retv = -1; FCopyInfo info; + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + for(int i=0;iCopyTrueColorTranslated(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, Parts[i].Translation, &info); + ret = Parts[i].Texture->CopyTrueColorTranslated(bmp, + x+Parts[i].OriginX, y+Parts[i].OriginY, + w-Parts[i].OriginX, h-Parts[i].OriginY, + Parts[i].Rotate, Parts[i].Translation, &info); } else { @@ -597,7 +603,10 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota info.blend = BLEND_OVERLAY; } } - ret = Parts[i].Texture->CopyTrueColorPixels(bmp, x+Parts[i].OriginX, y+Parts[i].OriginY, Parts[i].Rotate, &info); + ret = Parts[i].Texture->CopyTrueColorPixels(bmp, + x+Parts[i].OriginX, y+Parts[i].OriginY, + w-Parts[i].OriginX, h-Parts[i].OriginY, + Parts[i].Rotate, &info); } } else @@ -610,8 +619,11 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota if (bmp1.Create(Parts[i].Texture->GetWidth(), Parts[i].Texture->GetHeight())) { Parts[i].Texture->CopyTrueColorPixels(&bmp1, 0, 0); - bmp->CopyPixelDataRGB(x+Parts[i].OriginX, y+Parts[i].OriginY, bmp1.GetPixels(), - bmp1.GetWidth(), bmp1.GetHeight(), 4, bmp1.GetPitch()*4, Parts[i].Rotate, CF_BGRA, inf); + bmp->CopyPixelDataRGB( + x+Parts[i].OriginX, y+Parts[i].OriginY, bmp1.GetPixels(), + MIN(w-Parts[i].OriginX, bmp1.GetWidth()), + MIN(h-Parts[i].OriginY, bmp1.GetHeight()), + 4, bmp1.GetPitch()*4, Parts[i].Rotate, CF_BGRA, inf); } } diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 1a68d8996..e04bfa37e 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -91,7 +91,7 @@ public: void Unload (); FTextureFormat GetFormat (); - int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL); bool UseBasePalette(); protected: @@ -545,7 +545,7 @@ void FPCXTexture::MakeTexture() // //=========================================================================== -int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { PalEntry pe[256]; PCXHeader header; @@ -558,6 +558,9 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo bitcount = header.bitsPerPixel * header.numColorPlanes; + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + if (bitcount < 24) { Pixels = new BYTE[Width*Height]; @@ -599,13 +602,13 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo lump.Seek(sizeof(header), SEEK_SET); ReadPCX8bits (Pixels, lump, &header); } - bmp->CopyPixelData(x, y, Pixels, Width, Height, 1, Width, rotate, pe, inf); + bmp->CopyPixelData(x, y, Pixels, w, h, 1, Width, rotate, pe, inf); } else { Pixels = new BYTE[Width*Height * 3]; ReadPCX24bits (Pixels, lump, &header, 3); - bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, Width*3, rotate, CF_RGB, inf); + bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 3, Width*3, rotate, CF_RGB, inf); } delete [] Pixels; return 0; diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index e15f84f7d..253014070 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -58,7 +58,7 @@ public: const BYTE *GetPixels (); void Unload (); FTextureFormat GetFormat (); - int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL); bool UseBasePalette(); protected: @@ -577,7 +577,7 @@ void FPNGTexture::MakeTexture () // //=========================================================================== -int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { // Parse pre-IDAT chunks. I skip the CRCs. Is that bad? PalEntry pe[256]; @@ -587,6 +587,9 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo int pixwidth = Width * bpp[ColorType]; int transpal=false; + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + if (SourceLump >= 0) { lump = new FWadLump(Wads.OpenLumpNum(SourceLump)); @@ -640,20 +643,20 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo { case 0: case 3: - bmp->CopyPixelData(x, y, Pixels, Width, Height, 1, Width, rotate, pe, inf); + bmp->CopyPixelData(x, y, Pixels, w, h, 1, Width, rotate, pe, inf); break; case 2: - bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, pixwidth, rotate, CF_RGB, inf); + bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 3, pixwidth, rotate, CF_RGB, inf); break; case 4: - bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 2, pixwidth, rotate, CF_IA, inf); + bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 2, pixwidth, rotate, CF_IA, inf); transpal = -1; break; case 6: - bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 4, pixwidth, rotate, CF_RGBA, inf); + bmp->CopyPixelDataRGB(x, y, Pixels, w, h, 4, pixwidth, rotate, CF_RGBA, inf); transpal = -1; break; diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 026b2a863..8125c56b2 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -498,7 +498,7 @@ void FTexture::FillBuffer(BYTE *buff, int pitch, int height, FTextureFormat fmt) { FCopyInfo inf = {OP_OVERWRITE, }; FBitmap bmp(buff, pitch, pitch/4, height); - CopyTrueColorPixels(&bmp, 0, 0, 0, &inf); + CopyTrueColorPixels(&bmp, 0, 0, -1, -1, 0, &inf); break; } @@ -519,19 +519,23 @@ void FTexture::FillBuffer(BYTE *buff, int pitch, int height, FTextureFormat fmt) // //=========================================================================== -int FTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { PalEntry *palette = screen->GetPalette(); for(int i=1;i<256;i++) palette[i].a = 255; // set proper alpha values - bmp->CopyPixelData(x, y, GetPixels(), Width, Height, Height, 1, rotate, palette, inf); + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + bmp->CopyPixelData(x, y, GetPixels(), w, h, Height, 1, rotate, palette, inf); for(int i=1;i<256;i++) palette[i].a = 0; return 0; } -int FTexture::CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf) +int FTexture::CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int w, int h, int rotate, FRemapTable *remap, FCopyInfo *inf) { PalEntry *palette = remap->Palette; - bmp->CopyPixelData(x, y, GetPixels(), Width, Height, Height, 1, rotate, palette, inf); + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + bmp->CopyPixelData(x, y, GetPixels(), w, h, Height, 1, rotate, palette, inf); return 0; } diff --git a/src/textures/textures.h b/src/textures/textures.h index 06d373f1f..c96da0648 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -151,8 +151,8 @@ public: // Returns the whole texture, stored in column-major order virtual const BYTE *GetPixels () = 0; - virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); - int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL); + virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w=-1, int h=-1, int rotate=0, FCopyInfo *inf = NULL); + int CopyTrueColorTranslated(FBitmap *bmp, int x, int y,int w, int h, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL); virtual bool UseBasePalette(); virtual int GetSourceLump() { return SourceLump; } virtual FTexture *GetRedirect(bool wantwarped); diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index e14f7fb3d..c77ff264d 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -86,7 +86,7 @@ public: void Unload (); FTextureFormat GetFormat (); - int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf = NULL); bool UseBasePalette(); protected: @@ -491,12 +491,12 @@ void FTGATexture::MakeTexture () // //=========================================================================== -int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { PalEntry pe[256]; FWadLump lump = Wads.OpenLumpNum (SourceLump); TGAHeader hdr; - WORD w; + WORD wr; BYTE r,g,b,a; BYTE * sbuffer; int transval = 0; @@ -504,6 +504,9 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo lump.Read(&hdr, sizeof(hdr)); lump.Seek(hdr.id_len, SEEK_CUR); + if (w < 0 || w > Width) w = Width; + if (h < 0 || h > Height) h = Height; + #ifdef WORDS_BIGENDIAN hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); @@ -520,10 +523,10 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo { case 15: case 16: - lump >> w; - r = (w & 0x001F) << 3; - g = (w & 0x03E0) >> 2; - b = (w & 0x7C00) >> 7; + lump >> wr; + r = (wr & 0x001F) << 3; + g = (wr & 0x03E0) >> 2; + b = (wr & 0x7C00) >> 7; a = 255; break; @@ -576,7 +579,7 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo switch (hdr.img_type & 7) { case 1: // paletted - bmp->CopyPixelData(x, y, ptr, Width, Height, step_x, Pitch, rotate, pe, inf); + bmp->CopyPixelData(x, y, ptr, w, h, step_x, Pitch, rotate, pe, inf); break; case 2: // RGB @@ -584,21 +587,21 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo { case 15: case 16: - bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_RGB555, inf); + bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_RGB555, inf); break; case 24: - bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_BGR, inf); + bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_BGR, inf); break; case 32: if ((hdr.img_desc&15)!=8) // 32 bits without a valid alpha channel { - bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_BGR, inf); + bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_BGR, inf); } else { - bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_BGRA, inf); + bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_BGRA, inf); transval = -1; } break; @@ -613,11 +616,11 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo { case 8: for(int i=0;i<256;i++) pe[i]=PalEntry(255,i,i,i); // gray map - bmp->CopyPixelData(x, y, ptr, Width, Height, step_x, Pitch, rotate, pe, inf); + bmp->CopyPixelData(x, y, ptr, w, h, step_x, Pitch, rotate, pe, inf); break; case 16: - bmp->CopyPixelDataRGB(x, y, ptr, Width, Height, step_x, Pitch, rotate, CF_I16, inf); + bmp->CopyPixelDataRGB(x, y, ptr, w, h, step_x, Pitch, rotate, CF_I16, inf); break; default: diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index f87688ea1..8d6469779 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -242,8 +242,8 @@ FTexture *FWarpTexture::GetRedirect(bool wantwarped) // //========================================================================== -int FWarpTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +int FWarpTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, int rotate, FCopyInfo *inf) { - return SourcePic->CopyTrueColorPixels(bmp, x, y, rotate, inf); + return SourcePic->CopyTrueColorPixels(bmp, x, y, w, h, rotate, inf); }