The memset antipattern cannot be used on classes with a virtual table

This commit is contained in:
Magnus Norddahl 2017-01-24 02:28:32 +01:00
parent 55d9392fb8
commit 07acd9375b
8 changed files with 41 additions and 43 deletions

View file

@ -179,7 +179,6 @@ namespace swrenderer
// store information in a vissprite // store information in a vissprite
RenderParticle *vis = RenderMemory::NewObject<RenderParticle>(); RenderParticle *vis = RenderMemory::NewObject<RenderParticle>();
memset(vis, 0, sizeof(*vis));
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq; vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
vis->heightsec = heightsec; vis->heightsec = heightsec;

View file

@ -32,11 +32,11 @@ namespace swrenderer
private: private:
void DrawMaskedSegsBehindParticle(); void DrawMaskedSegsBehindParticle();
fixed_t xscale; fixed_t xscale = 0;
fixed_t startfrac; // horizontal position of x1 fixed_t startfrac = 0; // horizontal position of x1
int y1, y2; int y1 = 0, y2 = 0;
uint32_t Translation; uint32_t Translation = 0;
uint32_t FillColor; uint32_t FillColor = 0;
}; };
} }

View file

@ -273,7 +273,6 @@ namespace swrenderer
// store information in a vissprite // store information in a vissprite
RenderSprite *vis = &avis[vispspindex]; RenderSprite *vis = &avis[vispspindex];
memset(vis, 0, sizeof(*vis));
vis->renderflags = owner->renderflags; vis->renderflags = owner->renderflags;
vis->floorclip = 0; vis->floorclip = 0;

View file

@ -157,7 +157,6 @@ namespace swrenderer
// store information in a vissprite // store information in a vissprite
RenderSprite *vis = RenderMemory::NewObject<RenderSprite>(); RenderSprite *vis = RenderMemory::NewObject<RenderSprite>();
memset(vis, 0, sizeof(*vis));
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq; vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
vis->xscale = FLOAT2FIXED(xscale); vis->xscale = FLOAT2FIXED(xscale);

View file

@ -26,12 +26,12 @@ namespace swrenderer
void Render(short *cliptop, short *clipbottom, int minZ, int maxZ) override; void Render(short *cliptop, short *clipbottom, int minZ, int maxZ) override;
private: private:
fixed_t xscale; fixed_t xscale = 0;
fixed_t startfrac; // horizontal position of x1 fixed_t startfrac = 0; // horizontal position of x1
fixed_t xiscale; // negative if flipped fixed_t xiscale = 0; // negative if flipped
uint32_t Translation; uint32_t Translation = 0;
uint32_t FillColor; uint32_t FillColor = 0;
friend class RenderPlayerSprite; // To do: detach sprite from playersprite! friend class RenderPlayerSprite; // To do: detach sprite from playersprite!
}; };

View file

@ -26,6 +26,7 @@ namespace swrenderer
class VisibleSprite class VisibleSprite
{ {
public: public:
VisibleSprite() { RenderStyle = STYLE_Normal; }
virtual ~VisibleSprite() { } virtual ~VisibleSprite() { }
void Render(); void Render();
@ -45,38 +46,38 @@ namespace swrenderer
virtual void Render(short *cliptop, short *clipbottom, int minZ, int maxZ) = 0; virtual void Render(short *cliptop, short *clipbottom, int minZ, int maxZ) = 0;
FTexture *pic; FTexture *pic = nullptr;
short x1, x2; short x1 = 0, x2 = 0;
float gzb, gzt; // global bottom / top for silhouette clipping float gzb = 0.0f, gzt = 0.0f; // global bottom / top for silhouette clipping
double floorclip; double floorclip = 0.0;
double texturemid; // floorclip double texturemid = 0.0; // floorclip
float yscale; // voxel and floorclip float yscale = 0.0f; // voxel and floorclip
sector_t *heightsec; // height sector for underwater/fake ceiling sector_t *heightsec = nullptr; // height sector for underwater/fake ceiling
WaterFakeSide FakeFlatStat; // which side of fake/floor ceiling sprite is on WaterFakeSide FakeFlatStat = WaterFakeSide::Center; // which side of fake/floor ceiling sprite is on
F3DFloor *fakefloor; // 3d floor clipping F3DFloor *fakefloor = nullptr; // 3d floor clipping
F3DFloor *fakeceiling; F3DFloor *fakeceiling = nullptr;
FVector3 gpos; // origin in world coordinates FVector3 gpos = { 0.0f, 0.0f, 0.0f }; // origin in world coordinates
sector_t *sector; // sector this sprite is in sector_t *sector = nullptr; // sector this sprite is in
// Light shared calculation? // Light shared calculation?
int ColormapNum; // Which colormap is rendered int ColormapNum = 0; // Which colormap is rendered
FSWColormap *BaseColormap; // Base colormap used together with ColormapNum FSWColormap *BaseColormap = nullptr; // Base colormap used together with ColormapNum
float Alpha; float Alpha = 0.0f;
FRenderStyle RenderStyle; FRenderStyle RenderStyle;
bool foggy; bool foggy = false;
short renderflags; short renderflags = 0;
float depth; // Sort (draw segments), also light float depth = 0.0f; // Sort (draw segments), also light
float deltax, deltay; // Sort (2d/voxel version) float deltax = 0.0f, deltay = 0.0f; // Sort (2d/voxel version)
float idepth; // Sort (non-voxel version) float idepth = 0.0f; // Sort (non-voxel version)
int CurrentPortalUniq; // to identify the portal that this thing is in. used for clipping. int CurrentPortalUniq = 0; // to identify the portal that this thing is in. used for clipping.
}; };
} }

View file

@ -65,17 +65,17 @@ namespace swrenderer
private: private:
struct posang struct posang
{ {
FVector3 vpos; // view origin FVector3 vpos = { 0.0f, 0.0f, 0.0f }; // view origin
FAngle vang; // view angle FAngle vang = { 0.0f }; // view angle
}; };
posang pa; posang pa;
DAngle Angle; DAngle Angle = { 0.0 };
fixed_t xscale; fixed_t xscale = 0;
FVoxel *voxel; FVoxel *voxel = nullptr;
uint32_t Translation; uint32_t Translation = 0;
uint32_t FillColor; uint32_t FillColor = 0;
enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 }; enum { DVF_OFFSCREEN = 1, DVF_SPANSONLY = 2, DVF_MIRRORED = 4 };

View file

@ -30,7 +30,7 @@ namespace swrenderer
static void DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); static void DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip);
FWallCoords wallc; FWallCoords wallc;
uint32_t Translation; uint32_t Translation = 0;
uint32_t FillColor; uint32_t FillColor = 0;
}; };
} }