From b8625d9efbe6bcb6a443c4fd1091a1ef4e018479 Mon Sep 17 00:00:00 2001
From: Jaime Passos <lazymyuutsu@gmail.com>
Date: Fri, 3 Jan 2020 23:25:26 -0300
Subject: [PATCH] AA trees are not needed at all for rotated patches

---
 src/hardware/hw_cache.c | 17 -----------------
 src/hardware/hw_glob.h  |  3 ---
 src/r_defs.h            |  3 ---
 src/r_picformats.c      |  6 ++++--
 src/r_things.c          |  3 ---
 5 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c
index df1e18f9d5..d8f491f48b 100644
--- a/src/hardware/hw_cache.c
+++ b/src/hardware/hw_cache.c
@@ -1388,23 +1388,6 @@ GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum)
 	return HWR_GetCachedGLPatchPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum));
 }
 
-#ifdef ROTSPRITE
-GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch)
-{
-	GLPatch_t *grpatch;
-
-	if (!(grpatch = M_AATreeGet(hwrcache, rollangle)))
-	{
-		grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
-		grpatch->rawpatch = rawpatch;
-		grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
-		M_AATreeSet(hwrcache, rollangle, grpatch);
-	}
-
-	return grpatch;
-}
-#endif
-
 // Need to do this because they aren't powers of 2
 static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight,
 	lumpnum_t fademasklumpnum, UINT16 fmwidth, UINT16 fmheight)
diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h
index cf98e73173..a2bf79817a 100644
--- a/src/hardware/hw_glob.h
+++ b/src/hardware/hw_glob.h
@@ -113,9 +113,6 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum);
 void HWR_SetPalette(RGBA_t *palette);
 GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
 GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
-#ifdef ROTSPRITE
-GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch);
-#endif
 void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
 
 // --------
diff --git a/src/r_defs.h b/src/r_defs.h
index c7c198d662..176f33c4f9 100644
--- a/src/r_defs.h
+++ b/src/r_defs.h
@@ -729,9 +729,6 @@ typedef struct
 {
 	patch_t *patch[8][ROTANGLES];
 	boolean cached[8];
-#ifdef HWRENDER
-	aatree_t *hardware_patch[8];
-#endif/*HWRENDER*/
 } rotsprite_t;
 #endif/*ROTSPRITE*/
 
diff --git a/src/r_picformats.c b/src/r_picformats.c
index 35fb0c0559..e0688e31a6 100644
--- a/src/r_picformats.c
+++ b/src/r_picformats.c
@@ -1613,9 +1613,11 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
 #ifdef HWRENDER
 			if (rendermode == render_opengl)
 			{
-				GLPatch_t *grPatch = HWR_GetCachedGLRotSprite(sprframe->rotsprite.hardware_patch[rot], angle, newpatch);
-				HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false);
+				GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
+				grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
+				grPatch->rawpatch = newpatch;
 				sprframe->rotsprite.patch[rot][angle] = (patch_t *)grPatch;
+				HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false);
 			}
 			else
 #endif // HWRENDER
diff --git a/src/r_things.c b/src/r_things.c
index 5cd74ef7b1..0f1dc87cd3 100644
--- a/src/r_things.c
+++ b/src/r_things.c
@@ -125,9 +125,6 @@ static void R_InstallSpriteLump(UINT16 wad,            // graphics patch
 		sprtemp[frame].rotsprite.cached[r] = false;
 		for (ang = 0; ang < ROTANGLES; ang++)
 			sprtemp[frame].rotsprite.patch[r][ang] = NULL;
-#ifdef HWRENDER
-		sprtemp[frame].rotsprite.hardware_patch[r] = M_AATreeAlloc(AATREE_ZUSER);
-#endif/*HWRENDER*/
 	}
 #endif/*ROTSPRITE*/
 
-- 
GitLab