From 991f49e321e19752ebe24411f77ffa7d35476edf Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 23 Apr 2016 20:42:14 -0500 Subject: [PATCH] Avoid copying vissprite_t in R_DrawPSprites() --- src/r_things.cpp | 18 +++++++++++++----- src/r_things.h | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index ed77170fd9..24a3574369 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1284,12 +1284,20 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double WORD flip; FTexture* tex; vissprite_t* vis; - static vissprite_t avis[NUMPSPRITES]; - vissprite_t tempvis; + static vissprite_t avis[NUMPSPRITES + 1]; + static vissprite_t *avisp[countof(avis)]; bool noaccel; assert(pspnum >= 0 && pspnum < NUMPSPRITES); + if (avisp[0] == NULL) + { + for (int i = 0; i < countof(avis); ++i) + { + avisp[i] = &avis[i]; + } + } + // decide which patch to use if ( (unsigned)psp->sprite >= (unsigned)sprites.Size ()) { @@ -1329,7 +1337,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double return; // store information in a vissprite - vis = &tempvis; + vis = avisp[NUMPSPRITES]; vis->renderflags = owner->renderflags; vis->floorclip = 0; @@ -1499,8 +1507,8 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double { VisPSpritesX1[pspnum] = x1; VisPSpritesBaseColormap[pspnum] = colormap_to_use; - VisPSprites[pspnum] = &avis[pspnum]; - avis[pspnum] = *vis; + VisPSprites[pspnum] = vis; + swapvalues(avisp[pspnum], avisp[NUMPSPRITES]); return; } } diff --git a/src/r_things.h b/src/r_things.h index ee60e1bce7..6dd93787f4 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -88,7 +88,6 @@ struct vissprite_t int CurrentPortalUniq; // [ZZ] to identify the portal that this thing is in. used for clipping. vissprite_t() {} - vissprite_t &operator= (const vissprite_t &o) { memcpy(this, &o, sizeof *this); return *this; } }; struct particle_t;