mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 23:32:02 +00:00
Move vissprite to its own file
This commit is contained in:
parent
80e369541a
commit
f133b4caa4
5 changed files with 151 additions and 120 deletions
|
@ -826,6 +826,7 @@ set( FASTMATH_PCH_SOURCES
|
||||||
swrenderer/scene/r_portal_segment.cpp
|
swrenderer/scene/r_portal_segment.cpp
|
||||||
swrenderer/scene/r_portal.cpp
|
swrenderer/scene/r_portal.cpp
|
||||||
swrenderer/scene/r_visible_plane.cpp
|
swrenderer/scene/r_visible_plane.cpp
|
||||||
|
swrenderer/scene/r_visible_sprite.cpp
|
||||||
polyrenderer/poly_renderer.cpp
|
polyrenderer/poly_renderer.cpp
|
||||||
polyrenderer/scene/poly_scene.cpp
|
polyrenderer/scene/poly_scene.cpp
|
||||||
polyrenderer/scene/poly_portal.cpp
|
polyrenderer/scene/poly_portal.cpp
|
||||||
|
|
|
@ -161,12 +161,6 @@ FCoverageBuffer *OffscreenCoverageBuffer;
|
||||||
|
|
||||||
// GAME FUNCTIONS
|
// GAME FUNCTIONS
|
||||||
//
|
//
|
||||||
int MaxVisSprites;
|
|
||||||
vissprite_t **vissprites;
|
|
||||||
vissprite_t **firstvissprite;
|
|
||||||
vissprite_t **vissprite_p;
|
|
||||||
vissprite_t **lastvissprite;
|
|
||||||
int newvissprite;
|
|
||||||
bool DrewAVoxel;
|
bool DrewAVoxel;
|
||||||
|
|
||||||
static vissprite_t **spritesorter;
|
static vissprite_t **spritesorter;
|
||||||
|
@ -179,15 +173,7 @@ static void R_ProjectWallSprite(AActor *thing, const DVector3 &pos, FTextureID p
|
||||||
|
|
||||||
void R_DeinitSprites()
|
void R_DeinitSprites()
|
||||||
{
|
{
|
||||||
// Free vissprites
|
R_DeinitVisSprites();
|
||||||
for (int i = 0; i < MaxVisSprites; ++i)
|
|
||||||
{
|
|
||||||
delete vissprites[i];
|
|
||||||
}
|
|
||||||
free (vissprites);
|
|
||||||
vissprites = NULL;
|
|
||||||
vissprite_p = lastvissprite = NULL;
|
|
||||||
MaxVisSprites = 0;
|
|
||||||
|
|
||||||
// Free vissprites sorter
|
// Free vissprites sorter
|
||||||
if (spritesorter != NULL)
|
if (spritesorter != NULL)
|
||||||
|
@ -217,39 +203,10 @@ void R_DeinitSprites()
|
||||||
//
|
//
|
||||||
void R_ClearSprites (void)
|
void R_ClearSprites (void)
|
||||||
{
|
{
|
||||||
vissprite_p = firstvissprite;
|
R_ClearVisSprites();
|
||||||
DrewAVoxel = false;
|
DrewAVoxel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// R_NewVisSprite
|
|
||||||
//
|
|
||||||
vissprite_t *R_NewVisSprite (void)
|
|
||||||
{
|
|
||||||
if (vissprite_p == lastvissprite)
|
|
||||||
{
|
|
||||||
ptrdiff_t firstvisspritenum = firstvissprite - vissprites;
|
|
||||||
ptrdiff_t prevvisspritenum = vissprite_p - vissprites;
|
|
||||||
|
|
||||||
MaxVisSprites = MaxVisSprites ? MaxVisSprites * 2 : 128;
|
|
||||||
vissprites = (vissprite_t **)M_Realloc (vissprites, MaxVisSprites * sizeof(vissprite_t));
|
|
||||||
lastvissprite = &vissprites[MaxVisSprites];
|
|
||||||
firstvissprite = &vissprites[firstvisspritenum];
|
|
||||||
vissprite_p = &vissprites[prevvisspritenum];
|
|
||||||
DPrintf (DMSG_NOTIFY, "MaxVisSprites increased to %d\n", MaxVisSprites);
|
|
||||||
|
|
||||||
// Allocate sprites from the new pile
|
|
||||||
for (vissprite_t **p = vissprite_p; p < lastvissprite; ++p)
|
|
||||||
{
|
|
||||||
*p = new vissprite_t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vissprite_p++;
|
|
||||||
return *(vissprite_p-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_DrawMaskedColumn
|
// R_DrawMaskedColumn
|
||||||
// Used for sprites and masked mid textures.
|
// Used for sprites and masked mid textures.
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef __R_THINGS__
|
#ifndef __R_THINGS__
|
||||||
#define __R_THINGS__
|
#define __R_THINGS__
|
||||||
|
|
||||||
#include "r_bsp.h"
|
#include "r_visible_sprite.h"
|
||||||
|
|
||||||
struct particle_t;
|
struct particle_t;
|
||||||
struct FVoxel;
|
struct FVoxel;
|
||||||
|
@ -31,84 +31,10 @@ struct FVoxel;
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
|
|
||||||
// A vissprite_t is a thing
|
|
||||||
// that will be drawn during a refresh.
|
|
||||||
// I.e. a sprite object that is partly visible.
|
|
||||||
|
|
||||||
struct vissprite_t
|
|
||||||
{
|
|
||||||
struct posang
|
|
||||||
{
|
|
||||||
FVector3 vpos; // view origin
|
|
||||||
FAngle vang; // view angle
|
|
||||||
};
|
|
||||||
|
|
||||||
short x1, x2;
|
|
||||||
FVector3 gpos; // origin in world coordinates
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
float gzb, gzt; // global bottom / top for silhouette clipping
|
|
||||||
};
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
int y1, y2; // top / bottom of particle on screen
|
|
||||||
};
|
|
||||||
};
|
|
||||||
DAngle Angle;
|
|
||||||
fixed_t xscale;
|
|
||||||
float yscale;
|
|
||||||
float depth;
|
|
||||||
float idepth; // 1/z
|
|
||||||
float deltax, deltay;
|
|
||||||
DWORD FillColor;
|
|
||||||
double floorclip;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
FTexture *pic;
|
|
||||||
struct FVoxel *voxel;
|
|
||||||
};
|
|
||||||
union
|
|
||||||
{
|
|
||||||
// Used by face sprites
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
double texturemid;
|
|
||||||
fixed_t startfrac; // horizontal position of x1
|
|
||||||
fixed_t xiscale; // negative if flipped
|
|
||||||
};
|
|
||||||
// Used by wall sprites
|
|
||||||
FWallCoords wallc;
|
|
||||||
// Used by voxels
|
|
||||||
posang pa;
|
|
||||||
};
|
|
||||||
sector_t *heightsec; // killough 3/27/98: height sector for underwater/fake ceiling
|
|
||||||
sector_t *sector; // [RH] sector this sprite is in
|
|
||||||
F3DFloor *fakefloor;
|
|
||||||
F3DFloor *fakeceiling;
|
|
||||||
BYTE bIsVoxel:1; // [RH] Use voxel instead of pic
|
|
||||||
BYTE bWallSprite:1; // [RH] This is a wall sprite
|
|
||||||
BYTE bSplitSprite:1; // [RH] Sprite was split by a drawseg
|
|
||||||
BYTE bInMirror:1; // [RH] Sprite is "inside" a mirror
|
|
||||||
BYTE FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on
|
|
||||||
short renderflags;
|
|
||||||
DWORD Translation; // [RH] for color translation
|
|
||||||
visstyle_t Style;
|
|
||||||
int CurrentPortalUniq; // [ZZ] to identify the portal that this thing is in. used for clipping.
|
|
||||||
|
|
||||||
vissprite_t() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
void R_DrawParticle (vissprite_t *);
|
void R_DrawParticle (vissprite_t *);
|
||||||
|
|
||||||
void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside);
|
void R_ProjectParticle (particle_t *, const sector_t *sector, int shade, int fakeside);
|
||||||
|
|
||||||
extern int MaxVisSprites;
|
|
||||||
|
|
||||||
extern vissprite_t **vissprites, **firstvissprite;
|
|
||||||
extern vissprite_t **vissprite_p;
|
|
||||||
|
|
||||||
// Constant arrays used for psprite clipping
|
// Constant arrays used for psprite clipping
|
||||||
// and initializing clipping.
|
// and initializing clipping.
|
||||||
extern short zeroarray[MAXWIDTH];
|
extern short zeroarray[MAXWIDTH];
|
||||||
|
|
64
src/swrenderer/scene/r_visible_sprite.cpp
Normal file
64
src/swrenderer/scene/r_visible_sprite.cpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "p_lnspec.h"
|
||||||
|
#include "templates.h"
|
||||||
|
#include "doomdef.h"
|
||||||
|
#include "m_swap.h"
|
||||||
|
#include "i_system.h"
|
||||||
|
#include "w_wad.h"
|
||||||
|
#include "swrenderer/r_main.h"
|
||||||
|
#include "swrenderer/scene/r_visible_sprite.h"
|
||||||
|
|
||||||
|
namespace swrenderer
|
||||||
|
{
|
||||||
|
int MaxVisSprites;
|
||||||
|
vissprite_t **vissprites;
|
||||||
|
vissprite_t **firstvissprite;
|
||||||
|
vissprite_t **vissprite_p;
|
||||||
|
vissprite_t **lastvissprite;
|
||||||
|
|
||||||
|
void R_DeinitVisSprites()
|
||||||
|
{
|
||||||
|
// Free vissprites
|
||||||
|
for (int i = 0; i < MaxVisSprites; ++i)
|
||||||
|
{
|
||||||
|
delete vissprites[i];
|
||||||
|
}
|
||||||
|
free(vissprites);
|
||||||
|
vissprites = nullptr;
|
||||||
|
vissprite_p = lastvissprite = nullptr;
|
||||||
|
MaxVisSprites = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_ClearVisSprites()
|
||||||
|
{
|
||||||
|
vissprite_p = firstvissprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
vissprite_t *R_NewVisSprite()
|
||||||
|
{
|
||||||
|
if (vissprite_p == lastvissprite)
|
||||||
|
{
|
||||||
|
ptrdiff_t firstvisspritenum = firstvissprite - vissprites;
|
||||||
|
ptrdiff_t prevvisspritenum = vissprite_p - vissprites;
|
||||||
|
|
||||||
|
MaxVisSprites = MaxVisSprites ? MaxVisSprites * 2 : 128;
|
||||||
|
vissprites = (vissprite_t **)M_Realloc(vissprites, MaxVisSprites * sizeof(vissprite_t));
|
||||||
|
lastvissprite = &vissprites[MaxVisSprites];
|
||||||
|
firstvissprite = &vissprites[firstvisspritenum];
|
||||||
|
vissprite_p = &vissprites[prevvisspritenum];
|
||||||
|
DPrintf(DMSG_NOTIFY, "MaxVisSprites increased to %d\n", MaxVisSprites);
|
||||||
|
|
||||||
|
// Allocate sprites from the new pile
|
||||||
|
for (vissprite_t **p = vissprite_p; p < lastvissprite; ++p)
|
||||||
|
{
|
||||||
|
*p = new vissprite_t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vissprite_p++;
|
||||||
|
return *(vissprite_p - 1);
|
||||||
|
}
|
||||||
|
}
|
83
src/swrenderer/scene/r_visible_sprite.h
Normal file
83
src/swrenderer/scene/r_visible_sprite.h
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "r_bsp.h"
|
||||||
|
|
||||||
|
struct particle_t;
|
||||||
|
struct FVoxel;
|
||||||
|
|
||||||
|
namespace swrenderer
|
||||||
|
{
|
||||||
|
struct vissprite_t
|
||||||
|
{
|
||||||
|
struct posang
|
||||||
|
{
|
||||||
|
FVector3 vpos; // view origin
|
||||||
|
FAngle vang; // view angle
|
||||||
|
};
|
||||||
|
|
||||||
|
short x1, x2;
|
||||||
|
FVector3 gpos; // origin in world coordinates
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
float gzb, gzt; // global bottom / top for silhouette clipping
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int y1, y2; // top / bottom of particle on screen
|
||||||
|
};
|
||||||
|
};
|
||||||
|
DAngle Angle;
|
||||||
|
fixed_t xscale;
|
||||||
|
float yscale;
|
||||||
|
float depth;
|
||||||
|
float idepth; // 1/z
|
||||||
|
float deltax, deltay;
|
||||||
|
uint32_t FillColor;
|
||||||
|
double floorclip;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
FTexture *pic;
|
||||||
|
struct FVoxel *voxel;
|
||||||
|
};
|
||||||
|
union
|
||||||
|
{
|
||||||
|
// Used by face sprites
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
double texturemid;
|
||||||
|
fixed_t startfrac; // horizontal position of x1
|
||||||
|
fixed_t xiscale; // negative if flipped
|
||||||
|
};
|
||||||
|
// Used by wall sprites
|
||||||
|
FWallCoords wallc;
|
||||||
|
// Used by voxels
|
||||||
|
posang pa;
|
||||||
|
};
|
||||||
|
sector_t *heightsec; // killough 3/27/98: height sector for underwater/fake ceiling
|
||||||
|
sector_t *sector; // [RH] sector this sprite is in
|
||||||
|
F3DFloor *fakefloor;
|
||||||
|
F3DFloor *fakeceiling;
|
||||||
|
uint8_t bIsVoxel : 1; // [RH] Use voxel instead of pic
|
||||||
|
uint8_t bWallSprite : 1; // [RH] This is a wall sprite
|
||||||
|
uint8_t bSplitSprite : 1; // [RH] Sprite was split by a drawseg
|
||||||
|
uint8_t bInMirror : 1; // [RH] Sprite is "inside" a mirror
|
||||||
|
uint8_t FakeFlatStat; // [RH] which side of fake/floor ceiling sprite is on
|
||||||
|
short renderflags;
|
||||||
|
uint32_t Translation; // [RH] for color translation
|
||||||
|
visstyle_t Style;
|
||||||
|
int CurrentPortalUniq; // [ZZ] to identify the portal that this thing is in. used for clipping.
|
||||||
|
|
||||||
|
vissprite_t() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int MaxVisSprites;
|
||||||
|
extern vissprite_t **vissprites, **firstvissprite;
|
||||||
|
extern vissprite_t **vissprite_p;
|
||||||
|
|
||||||
|
void R_DeinitVisSprites();
|
||||||
|
void R_ClearVisSprites();
|
||||||
|
vissprite_t *R_NewVisSprite();
|
||||||
|
}
|
Loading…
Reference in a new issue