Skip to content

Commit

Permalink
[SP/MP] Match most of tr_types.h
Browse files Browse the repository at this point in the history
Flags and structs should match perfectly now. Also removes some miniRefEntity structs from MP that aren't used and are also made useless already. So, just some cleanup in this regard.
  • Loading branch information
SomaZ committed Dec 12, 2023
1 parent 35b799f commit 51ff8fa
Show file tree
Hide file tree
Showing 16 changed files with 366 additions and 156 deletions.
225 changes: 169 additions & 56 deletions code/rd-common/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#define MAX_REFENTITIES ((1<<REFENTITYNUM_BITS) - 1)
#define REFENTITYNUM_WORLD ((1<<REFENTITYNUM_BITS) - 1)

#define MAX_MINI_ENTITIES 1024

// renderfx flags
#define RF_MORELIGHT 0x00001 // allways have some light (viewmodel, some items)
#define RF_MINLIGHT 0x00001 // allways have some light (viewmodel, some items)
#define RF_THIRD_PERSON 0x00002 // don't draw through eyes, only mirrors (player bodies, chat sprites)
#define RF_FIRST_PERSON 0x00004 // only draw through eyes (view weapon, damage blood blob)
#define RF_DEPTHHACK 0x00008 // for view weapon Z crunching
Expand All @@ -53,28 +55,33 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#define RF_SHADOW_PLANE 0x00100 // use refEntity->shadowPlane
#define RF_WRAP_FRAMES 0x00200 // mod the model frames by the maxframes to allow continuous
// animation without needing to know the frame count
#define RF_CAP_FRAMES 0x00400 // cap the model frames by the maxframes for one shot anims

#define RF_ALPHA_FADE 0x00800 // hacks blend mode and uses whatever the set alpha is.
#define RF_PULSATE 0x01000 // for things like a dropped saber, where we want to add an extra visual clue
#define RF_RGB_TINT 0x02000 // overrides ent RGB color to the specified color
#define RF_FORCE_ENT_ALPHA 0x00400 // override shader alpha settings
#define RF_RGB_TINT 0x00800 // override shader rgb settings

#define RF_SHADOW_ONLY 0x01000 //add surfs for shadowing but don't draw them -rww

#define RF_DISTORTION 0x02000 //area distortion effect -rww

#define RF_FORKED 0x04000 // override lightning to have forks
#define RF_TAPERED 0x08000 // lightning tapers
#define RF_GROW 0x10000 // lightning grows from start to end during its life

#define RF_SETANIMINDEX 0x20000 //use backEnd.currentEntity->e.skinNum for R_BindAnimatedImage

#define RF_DISINTEGRATE1 0x40000 // does a procedural hole-ripping thing.
#define RF_DISINTEGRATE2 0x80000 // does a procedural hole-ripping thing with scaling at the ripping point
#define RF_DISINTEGRATE1 0x20000 // does a procedural hole-ripping thing.
#define RF_DISINTEGRATE2 0x40000 // does a procedural hole-ripping thing with scaling at the ripping point

#define RF_G2MINLOD 0x100000 // force Lowest lod on g2
#define RF_SETANIMINDEX 0x80000 //use backEnd.currentEntity->e.skinNum for R_BindAnimatedImage

#define RF_SHADOW_ONLY 0x200000 //add surfs for shadowing but don't draw them normally -rww
#define RF_ALPHA_DEPTH 0x100000 //depth write on alpha model

#define RF_DISTORTION 0x400000 //area distortion effect -rww
#define RF_FORCEPOST 0x200000 //force it to post-render -rww

#define RF_FORCE_ENT_ALPHA 0x800000 // override shader alpha settings
// SP renderfx flags, only use in SP!
#define RF_CAP_FRAMES 0x400000 // cap the model frames by the maxframes for one shot anims
#define RF_ALPHA_FADE 0x800000 // hacks blend mode and uses whatever the set alpha is.
#define RF_PULSATE 0x1000000 // for things like a dropped saber, where we want to add an extra visual clue
#define RF_G2MINLOD 0x2000000 // force Lowest lod on g2
#define RF_MORELIGHT 0x4000000 // allways have some light (viewmodel, some items) | SP version which is different from MP

// refdef flags
#define RDF_NOWORLDMODEL 1 // used for player configuration screen
Expand All @@ -83,9 +90,12 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#define RDF_SKYBOXPORTAL 8
#define RDF_DRAWSKYBOX 16 // the above marks a scene as being a 'portal sky'. this flag says to draw it or not

#define RDF_doLAGoggles 32 // Light Amp goggles
#define RDF_doFullbright 64 // Light Amp goggles
#define RDF_ForceSightOn 128 // using force sight
#define RDF_AUTOMAP 32 // MP only means this scene is to draw the automap -rww
#define RDF_NOFOG 64 // MP only no global fog in this scene (but still brush fog) -rww
#define RDF_ForceSightOn 128 //using force sight

#define RDF_doLAGoggles 256 // SP only Light Amp goggles
#define RDF_doFullbright 512 // SP only Light Amp goggles


extern int skyboxportal;
Expand All @@ -105,77 +115,178 @@ typedef struct poly_s {
polyVert_t *verts;
} poly_t;

typedef enum
{
typedef enum {
RT_MODEL,
RT_POLY,
RT_SPRITE,
RT_ORIENTED_QUAD,
RT_LINE,
RT_ELECTRICITY,
RT_CYLINDER,
RT_LATHE,
RT_BEAM,
RT_SABER_GLOW,
RT_ELECTRICITY,
RT_PORTALSURFACE, // doesn't draw anything, just info for portals
RT_LINE,
RT_ORIENTEDLINE,
RT_CYLINDER,
RT_ENT_CHAIN,

RT_MAX_MP_REF_ENTITY_TYPE,
// SP ONLY Entity Types!
RT_LATHE,
RT_CLOUDS,

RT_MAX_REF_ENTITY_TYPE
RT_MAX_SP_REF_ENTITY_TYPE
} refEntityType_t;

typedef struct {
refEntityType_t reType;
int renderfx;
typedef struct miniRefEntity_s
{
refEntityType_t reType;
int renderfx;

qhandle_t hModel; // opaque type outside refresh
qhandle_t hModel; // opaque type outside refresh

// most recent data
vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
float shadowPlane; // projection shadows go here, stencils go slightly lower
matrix3_t axis; // rotation vectors
qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale
vec3_t origin; // also used as MODEL_BEAM's "from"

// previous data for frame interpolation
vec3_t oldorigin; // also used as MODEL_BEAM's "to"

// texturing
qhandle_t customShader; // use one image for the entire thing

vec3_t axis[3]; // rotation vectors
qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale
float origin[3]; // also used as MODEL_BEAM's "from"
// misc
byte shaderRGBA[4]; // colors used by rgbgen entity shaders
vec2_t shaderTexCoord; // texture coordinates used by tcMod entity modifiers

// extra sprite information
float radius;
float rotation; // size 2 for RT_CYLINDER or number of verts in RT_ELECTRICITY

// misc
float shaderTime; // subtracted from refdef time to control effect start times
int frame; // also used as MODEL_BEAM's diameter

} miniRefEntity_t;

typedef struct refEntity_s {
// this stucture must remain identical as the miniRefEntity_t
//
//
refEntityType_t reType;
int renderfx;

qhandle_t hModel; // opaque type outside refresh

// most recent data
matrix3_t axis; // rotation vectors
qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale
vec3_t origin; // also used as MODEL_BEAM's "from"

// previous data for frame interpolation
float oldorigin[3]; // also used as MODEL_BEAM's "to"
int oldframe;
float backlerp; // 0.0 = current, 1.0 = old
vec3_t oldorigin; // also used as MODEL_BEAM's "to"

// texturing
int skinNum; // inline skin index
qhandle_t customShader; // use one image for the entire thing

qhandle_t customSkin; // NULL for default skin
qhandle_t customShader; // use one image for the entire thing
// misc
byte shaderRGBA[4]; // colors used by rgbgen entity shaders
vec2_t shaderTexCoord; // texture coordinates used by tcMod entity modifiers

// extra sprite information
float radius;
float rotation;

// misc
byte shaderRGBA[4]; // colors used by colorSrc=vertex shaders
float shaderTexCoord[2]; // texture coordinates used by tcMod=vertex modifiers
float shaderTime; // subtracted from refdef time to control effect start times
int frame; // also used as MODEL_BEAM's diameter
//
//
// end miniRefEntity_t

// extra sprite information
float radius;
//
//
// specific full refEntity_t data
//
//

// most recent data
vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
float shadowPlane; // projection shadows go here, stencils go slightly lower

// This doesn't have to be unioned, but it does make for more meaningful variable names :)
// previous data for frame interpolation
int oldframe;
float backlerp; // 0.0 = current, 1.0 = old

// texturing
int skinNum; // inline skin index
qhandle_t customSkin; // NULL for default skin

// texturing
union
{
float rotation;
float endTime;
float saberLength;
};
// int skinNum; // inline skin index
// ivec3_t terxelCoords; // coords of patch for RT_TERXELS
struct
{
int miniStart;
int miniCount;
} uMini;
} uRefEnt;

/*
Ghoul2 Insert Start
*/
// extra sprite information
union {
struct
{
float rotation;
float radius;
byte vertRGBA[4][4];
} sprite;
struct
{
float width;
float width2;
float stscale;
} line;
struct // that whole put-the-opening-brace-on-the-same-line-as-the-beginning-of-the-definition coding style is fecal
{
float width;
vec3_t control1;
vec3_t control2;
} bezier;
struct
{
float width;
float width2;
float stscale;
float height;
float bias;
qboolean wrap;
} cylinder;
struct
{
float width;
float deviation;
float stscale;
qboolean wrap;
qboolean taper;
} electricity;
} data;

float endTime;
float saberLength;

/*
Ghoul2 Insert Start
*/
vec3_t angles; // rotation angles - used for Ghoul2

vec3_t modelScale; // axis scale for models
CGhoul2Info_v *ghoul2; // has to be at the end of the ref-ent in order for it to be created properly
// CGhoul2Info_v *ghoul2; // has to be at the end of the ref-ent in order for it to be created properly
void *ghoul2; // has to be at the end of the ref-ent in order for it to be created properly
/*
Ghoul2 Insert End
*/

} refEntity_t;

#define MAX_RENDER_STRINGS 8
Expand All @@ -185,7 +296,8 @@ typedef struct {
int x, y, width, height;
float fov_x, fov_y;
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
vec3_t viewangles;
matrix3_t viewaxis; // transformation matrix
int viewContents; // world contents at vieworg

// time in milliseconds for shader effects and other time dependent rendering issues
Expand All @@ -195,6 +307,9 @@ typedef struct {

// 1 bits will prevent the associated area from rendering at all
byte areamask[MAX_MAP_AREA_BYTES];

// text messages for deform text shaders
char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];
} refdef_t;


Expand Down Expand Up @@ -224,6 +339,7 @@ typedef struct glconfig_s {
const char *vendor_string;
const char *version_string;
const char *extensions_string;

int maxTextureSize; // queried from GL
int maxActiveTextures; // multitexture ability
float maxTextureFilterAnisotropy;
Expand All @@ -233,15 +349,12 @@ typedef struct glconfig_s {
qboolean deviceSupportsGamma;
textureCompression_t textureCompression;
qboolean textureEnvAddAvailable;
qboolean textureFilterAnisotropicAvailable;
qboolean clampToEdgeAvailable;

int vidWidth, vidHeight;

int displayFrequency;

qboolean doStencilShadowsInOneDrawcall;

// synonymous with "does rendering consume the entire screen?", therefore
// a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that
// used CDS.
Expand Down
2 changes: 1 addition & 1 deletion code/rd-vanilla/tr_ghoul2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent ) {
}

assert (ent->e.ghoul2); //entity is foo if it has a glm model handle but no ghoul2 pointer!
CGhoul2Info_v &ghoul2 = *ent->e.ghoul2;
CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)ent->e.ghoul2);

if (!G2_SetupModelPointers(ghoul2))
{
Expand Down
5 changes: 3 additions & 2 deletions code/rd-vanilla/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
#include "tr_WorldEffects.h"

glconfig_t glConfig;
glconfigExt_t glConfigExt;
glstate_t glState;
window_t window;

Expand Down Expand Up @@ -677,10 +678,10 @@ static void GLimp_InitExtensions( void )
qglStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)ri.GL_GetProcAddress("glStencilOpSeparate");
if (qglStencilOpSeparate)
{
glConfig.doStencilShadowsInOneDrawcall = qtrue;
glConfigExt.doStencilShadowsInOneDrawcall = qtrue;
}
#else
glConfig.doStencilShadowsInOneDrawcall = qtrue;
glConfigExt.doStencilShadowsInOneDrawcall = qtrue;
#endif
}

Expand Down
11 changes: 11 additions & 0 deletions code/rd-vanilla/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,16 @@ typedef struct {
float distanceCull;
} trGlobals_t;

struct glconfigExt_t
{
glconfig_t *glConfig;

qboolean textureFilterAnisotropicAvailable;
qboolean doGammaCorrectionWithShaders;
qboolean doStencilShadowsInOneDrawcall;
const char *originalExtensionString;
};

int R_Images_StartIteration(void);
image_t *R_Images_GetNextIteration(void);
void R_Images_Clear(void);
Expand All @@ -1076,6 +1086,7 @@ void R_Images_DeleteImage(image_t *pImage);
extern backEndState_t backEnd;
extern trGlobals_t tr;
extern glconfig_t glConfig; // outside of TR since it shouldn't be cleared during ref re-init
extern glconfigExt_t glConfigExt;
extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init
extern window_t window;

Expand Down
Loading

0 comments on commit 51ff8fa

Please sign in to comment.