From 51ff8fa924c99e6787ffd885aa1e7acba412ac7c Mon Sep 17 00:00:00 2001
From: SomaZ <17459161+SomaZ@users.noreply.github.com>
Date: Tue, 12 Dec 2023 16:35:01 +0100
Subject: [PATCH] [SP/MP] Match most of tr_types.h
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.
---
code/rd-common/tr_types.h | 225 +++++++++++++++++++++++--------
code/rd-vanilla/tr_ghoul2.cpp | 2 +-
code/rd-vanilla/tr_init.cpp | 5 +-
code/rd-vanilla/tr_local.h | 11 ++
code/rd-vanilla/tr_scene.cpp | 40 +++++-
code/rd-vanilla/tr_shadows.cpp | 2 +-
code/rd-vanilla/tr_surface.cpp | 108 ++++++++++++++-
codemp/rd-common/tr_types.h | 18 ++-
codemp/rd-vanilla/tr_local.h | 2 +-
codemp/rd-vanilla/tr_scene.cpp | 57 +-------
codemp/rd-vanilla/tr_surface.cpp | 12 +-
shared/rd-rend2/tr_light.cpp | 13 +-
shared/rd-rend2/tr_local.h | 6 +-
shared/rd-rend2/tr_main.cpp | 6 -
shared/rd-rend2/tr_scene.cpp | 8 +-
shared/rd-rend2/tr_surface.cpp | 7 -
16 files changed, 366 insertions(+), 156 deletions(-)
diff --git a/code/rd-common/tr_types.h b/code/rd-common/tr_types.h
index 56e8704c49..6e6d63eba9 100644
--- a/code/rd-common/tr_types.h
+++ b/code/rd-common/tr_types.h
@@ -35,8 +35,10 @@ along with this program; if not, see .
#define MAX_REFENTITIES ((1<.
#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
@@ -83,9 +90,12 @@ along with this program; if not, see .
#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;
@@ -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
@@ -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
@@ -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;
@@ -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;
@@ -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.
diff --git a/code/rd-vanilla/tr_ghoul2.cpp b/code/rd-vanilla/tr_ghoul2.cpp
index b1f6d43a6b..d51432f223 100644
--- a/code/rd-vanilla/tr_ghoul2.cpp
+++ b/code/rd-vanilla/tr_ghoul2.cpp
@@ -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))
{
diff --git a/code/rd-vanilla/tr_init.cpp b/code/rd-vanilla/tr_init.cpp
index 13c72e66ee..b5423dc1b6 100644
--- a/code/rd-vanilla/tr_init.cpp
+++ b/code/rd-vanilla/tr_init.cpp
@@ -33,6 +33,7 @@ along with this program; if not, see .
#include "tr_WorldEffects.h"
glconfig_t glConfig;
+glconfigExt_t glConfigExt;
glstate_t glState;
window_t window;
@@ -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
}
diff --git a/code/rd-vanilla/tr_local.h b/code/rd-vanilla/tr_local.h
index 81597d4f03..9ded5e3de3 100644
--- a/code/rd-vanilla/tr_local.h
+++ b/code/rd-vanilla/tr_local.h
@@ -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);
@@ -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;
diff --git a/code/rd-vanilla/tr_scene.cpp b/code/rd-vanilla/tr_scene.cpp
index f41b4b2dac..ff78895241 100644
--- a/code/rd-vanilla/tr_scene.cpp
+++ b/code/rd-vanilla/tr_scene.cpp
@@ -220,7 +220,13 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
#endif
return;
}
- if ( ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) {
+
+ if (ent->reType == RT_ENT_CHAIN)
+ { //minirefents must die.
+ return;
+ }
+
+ if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_SP_REF_ENTITY_TYPE || ent->reType == RT_MAX_MP_REF_ENTITY_TYPE ) {
Com_Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType );
}
@@ -231,6 +237,38 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
}
+/************************************************************************************************
+ * RE_AddMiniRefEntityToScene *
+ * Adds a mini ref ent to the scene. If the input parameter is null, it signifies the end *
+ * of the chain. Otherwise, if there is a valid chain parent, it will be added to that. *
+ * If there is no parent, it will be added as a regular ref ent. *
+ * *
+ * Input *
+ * ent: the mini ref ent to be added *
+ * *
+ * Output / Return *
+ * none *
+ * *
+ ************************************************************************************************/
+void RE_AddMiniRefEntityToScene(const miniRefEntity_t *ent)
+{
+ if (!tr.registered)
+ {
+ return;
+ }
+ if (!ent)
+ {
+ return;
+ }
+
+ refEntity_t tempEnt;
+
+ memcpy(&tempEnt, ent, sizeof(*ent));
+ memset(((char *)&tempEnt) + sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent));
+ RE_AddRefEntityToScene(&tempEnt);
+}
+
+
/*
=====================
RE_AddLightToScene
diff --git a/code/rd-vanilla/tr_shadows.cpp b/code/rd-vanilla/tr_shadows.cpp
index c0331e9763..4e415e9d84 100644
--- a/code/rd-vanilla/tr_shadows.cpp
+++ b/code/rd-vanilla/tr_shadows.cpp
@@ -350,7 +350,7 @@ void RB_DoShadowTessEnd( vec3_t lightPos )
qglDepthFunc(GL_LESS);
//now using the Carmack Reverse -rww
- if (glConfig.doStencilShadowsInOneDrawcall)
+ if (glConfigExt.doStencilShadowsInOneDrawcall)
{
GL_Cull(CT_TWO_SIDED);
qglStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
diff --git a/code/rd-vanilla/tr_surface.cpp b/code/rd-vanilla/tr_surface.cpp
index 1e51e71c90..207a99986e 100644
--- a/code/rd-vanilla/tr_surface.cpp
+++ b/code/rd-vanilla/tr_surface.cpp
@@ -366,6 +366,62 @@ static void DoLine2( const vec3_t start, const vec3_t end, const vec3_t up, floa
tess.indexes[tess.numIndexes++] = vbase + 3;
}
+static void DoLine_Oriented(const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth)
+{
+ float spanWidth2;
+ int vbase;
+
+ vbase = tess.numVertexes;
+
+ spanWidth2 = -spanWidth;
+
+ // FIXME: use quad stamp?
+ VectorMA(start, spanWidth, up, tess.xyz[tess.numVertexes]);
+ tess.texCoords[tess.numVertexes][0][0] = 0;
+ tess.texCoords[tess.numVertexes][0][1] = 0;
+ tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25;
+ tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25;
+ tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25;
+ tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25;
+ tess.numVertexes++;
+
+ VectorMA(start, spanWidth2, up, tess.xyz[tess.numVertexes]);
+ tess.texCoords[tess.numVertexes][0][0] = 1;
+ tess.texCoords[tess.numVertexes][0][1] = 0;
+ tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
+ tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
+ tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
+ tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25;
+ tess.numVertexes++;
+
+ VectorMA(end, spanWidth, up, tess.xyz[tess.numVertexes]);
+
+ tess.texCoords[tess.numVertexes][0][0] = 0;
+ tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale;
+ tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
+ tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
+ tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
+ tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25;
+ tess.numVertexes++;
+
+ VectorMA(end, spanWidth2, up, tess.xyz[tess.numVertexes]);
+ tess.texCoords[tess.numVertexes][0][0] = 1;
+ tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale;
+ tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];
+ tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];
+ tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];
+ tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25;
+ tess.numVertexes++;
+
+ tess.indexes[tess.numIndexes++] = vbase;
+ tess.indexes[tess.numIndexes++] = vbase + 1;
+ tess.indexes[tess.numIndexes++] = vbase + 2;
+
+ tess.indexes[tess.numIndexes++] = vbase + 2;
+ tess.indexes[tess.numIndexes++] = vbase + 1;
+ tess.indexes[tess.numIndexes++] = vbase + 3;
+}
+
//-----------------
// RB_SurfaceLine
//-----------------
@@ -390,6 +446,23 @@ static void RB_SurfaceLine( void )
DoLine( start, end, right, e->radius);
}
+static void RB_SurfaceOrientedLine(void)
+{
+ refEntity_t *e;
+ vec3_t right;
+ vec3_t start, end;
+
+ e = &backEnd.currentEntity->e;
+
+ VectorCopy(e->oldorigin, end);
+ VectorCopy(e->origin, start);
+
+ // compute side vector
+ VectorNormalize(e->axis[1]);
+ VectorCopy(e->axis[1], right);
+ DoLine_Oriented(start, end, right, e->data.line.width*0.5);
+}
+
/*
==============
RB_SurfaceCylinder
@@ -1951,14 +2024,17 @@ void RB_SurfaceEntity( surfaceType_t *surfType ) {
case RT_ORIENTED_QUAD:
RB_SurfaceOrientedQuad();
break;
- case RT_LINE:
- RB_SurfaceLine();
+ case RT_BEAM:
+ RB_SurfaceBeam();
break;
case RT_ELECTRICITY:
RB_SurfaceElectricity();
break;
- case RT_BEAM:
- RB_SurfaceBeam();
+ case RT_LINE:
+ RB_SurfaceLine();
+ break;
+ case RT_ORIENTEDLINE:
+ RB_SurfaceOrientedLine();
break;
case RT_SABER_GLOW:
RB_SurfaceSaberGlow();
@@ -1966,6 +2042,30 @@ void RB_SurfaceEntity( surfaceType_t *surfType ) {
case RT_CYLINDER:
RB_SurfaceCylinder();
break;
+ case RT_ENT_CHAIN:
+ {
+ static trRefEntity_t tempEnt = *backEnd.currentEntity;
+
+ //rww - if not static then currentEntity is garbage because
+ //this is a local. This was not static in sof2.. but I guess
+ //they never check ce.renderfx so it didn't show up.
+
+ const int start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart;
+ const int count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount;
+ assert(count > 0);
+ backEnd.currentEntity = &tempEnt;
+
+ assert(backEnd.currentEntity->e.renderfx >= 0);
+
+ for (int i = 0, j = start; i < count; i++, j++)
+ {
+ backEnd.currentEntity->e = backEnd.refdef.entities[j].e;
+ assert(backEnd.currentEntity->e.renderfx >= 0);
+
+ RB_SurfaceEntity(surfType);
+ }
+ }
+ break;
case RT_LATHE:
RB_SurfaceLathe();
break;
diff --git a/codemp/rd-common/tr_types.h b/codemp/rd-common/tr_types.h
index 119d1a27b8..d35e9030b3 100644
--- a/codemp/rd-common/tr_types.h
+++ b/codemp/rd-common/tr_types.h
@@ -75,6 +75,13 @@ along with this program; if not, see .
#define RF_FORCEPOST 0x200000 //force it to post-render -rww
+// 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
#define RDF_HYPERSPACE 4 // teleportation effect
@@ -86,6 +93,10 @@ along with this program; if not, see .
#define RDF_NOFOG 64 //no global fog in this scene (but still brush fog) -rww
#define RDF_ForceSightOn 128 //using force sight
+// SP refdef flags, only use in SP!
+#define RDF_doLAGoggles 256 // SP only Light Amp goggles
+#define RDF_doFullbright 512 // SP only Light Amp goggles
+
extern int skyboxportal;
extern int drawskyboxportal;
@@ -117,7 +128,12 @@ typedef enum {
RT_CYLINDER,
RT_ENT_CHAIN,
- RT_MAX_REF_ENTITY_TYPE
+ RT_MAX_MP_REF_ENTITY_TYPE,
+ // SP ONLY Entity Types!
+ RT_LATHE,
+ RT_CLOUDS,
+
+ RT_MAX_SP_REF_ENTITY_TYPE
} refEntityType_t;
typedef struct miniRefEntity_s
diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h
index 2c55d9bfb1..70a27297ca 100644
--- a/codemp/rd-vanilla/tr_local.h
+++ b/codemp/rd-vanilla/tr_local.h
@@ -554,7 +554,6 @@ typedef struct trRefdef_s {
int num_entities;
trRefEntity_t *entities;
- trMiniRefEntity_t *miniEntities;
int num_dlights;
struct dlight_s *dlights;
@@ -1103,6 +1102,7 @@ struct glconfigExt_t
{
glconfig_t *glConfig;
+ qboolean textureFilterAnisotropicAvailable;
qboolean doGammaCorrectionWithShaders;
qboolean doStencilShadowsInOneDrawcall;
const char *originalExtensionString;
diff --git a/codemp/rd-vanilla/tr_scene.cpp b/codemp/rd-vanilla/tr_scene.cpp
index 9c0025485a..473d01e182 100644
--- a/codemp/rd-vanilla/tr_scene.cpp
+++ b/codemp/rd-vanilla/tr_scene.cpp
@@ -36,8 +36,6 @@ static int r_firstSceneDlight;
static int r_numentities;
static int r_firstSceneEntity;
static int r_numminientities;
-static int r_firstSceneMiniEntity;
-static int refEntParent = -1;
static int r_numpolys;
static int r_firstScenePoly;
@@ -63,9 +61,7 @@ void R_InitNextFrame( void ) {
r_numentities = 0;
r_firstSceneEntity = 0;
- refEntParent = -1;
r_numminientities = 0;
- r_firstSceneMiniEntity = 0;
r_numpolys = 0;
r_firstScenePoly = 0;
@@ -84,8 +80,6 @@ void RE_ClearScene( void ) {
r_firstSceneDlight = r_numdlights;
r_firstSceneEntity = r_numentities;
r_firstScenePoly = r_numpolys;
- refEntParent = -1;
- r_firstSceneMiniEntity = r_numminientities;
}
/*
@@ -238,8 +232,8 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
assert(ent->hModel || ent->ghoul2 || ent->customShader);
}
#endif
-
- if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) {
+ // TODO: We could implement RT_LATHE and RT_CLOUDS here in MP too to check the same as in the SP renderer -> less differences
+ if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_MP_REF_ENTITY_TYPE ) {
Com_Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType );
}
@@ -256,19 +250,6 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
}
}
- /*
- if (ent->reType == RT_ENT_CHAIN)
- {
- refEntParent = r_numentities;
- backEndData->entities[r_numentities].e.uRefEnt.uMini.miniStart = r_numminientities - r_firstSceneMiniEntity;
- backEndData->entities[r_numentities].e.uRefEnt.uMini.miniCount = 0;
- }
- else
- {
- */
- refEntParent = -1;
- //}
-
r_numentities++;
}
@@ -288,50 +269,20 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
************************************************************************************************/
void RE_AddMiniRefEntityToScene( const miniRefEntity_t *ent )
{
-#if 0
- refEntity_t *parent;
-#endif
-
if ( !tr.registered )
{
return;
}
if (!ent)
{
- refEntParent = -1;
return;
}
-#if 1 //i hate you minirefent!
refEntity_t tempEnt;
memcpy(&tempEnt, ent, sizeof(*ent));
memset(((char *)&tempEnt)+sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent));
RE_AddRefEntityToScene(&tempEnt);
-#else
-
- if ( ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE )
- {
- Com_Error( ERR_DROP, "RE_AddMiniRefEntityToScene: bad reType %i", ent->reType );
- }
-
- if (!r_numentities || refEntParent == -1 || r_numminientities >= MAX_MINI_ENTITIES)
- { //rww - add it as a refent also if we run out of minis
-// Com_Error( ERR_DROP, "RE_AddMiniRefEntityToScene: mini without parent ref ent");
- refEntity_t tempEnt;
-
- memcpy(&tempEnt, ent, sizeof(*ent));
- memset(((char *)&tempEnt)+sizeof(*ent), 0, sizeof(tempEnt) - sizeof(*ent));
- RE_AddRefEntityToScene(&tempEnt);
- return;
- }
-
- parent = &backEndData->entities[refEntParent].e;
- parent->uRefEnt.uMini.miniCount++;
-
- backEndData->miniEntities[r_numminientities].e = *ent;
- r_numminientities++;
-#endif
}
/*
@@ -491,7 +442,6 @@ void RE_RenderScene( const refdef_t *fd ) {
tr.refdef.num_entities = r_numentities - r_firstSceneEntity;
tr.refdef.entities = &backEndData->entities[r_firstSceneEntity];
- tr.refdef.miniEntities = &backEndData->miniEntities[r_firstSceneMiniEntity];
tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight;
tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight];
@@ -549,12 +499,9 @@ void RE_RenderScene( const refdef_t *fd ) {
// the next scene rendered in this frame will tack on after this one
r_firstSceneDrawSurf = tr.refdef.numDrawSurfs;
r_firstSceneEntity = r_numentities;
- r_firstSceneMiniEntity = r_numminientities;
r_firstSceneDlight = r_numdlights;
r_firstScenePoly = r_numpolys;
- refEntParent = -1;
-
tr.frontEndMsec += ri.Milliseconds()*ri.Cvar_VariableValue( "timescale" ) - startTime;
RE_RenderWorldEffects();
diff --git a/codemp/rd-vanilla/tr_surface.cpp b/codemp/rd-vanilla/tr_surface.cpp
index 3be021dce6..ab8bf97303 100644
--- a/codemp/rd-vanilla/tr_surface.cpp
+++ b/codemp/rd-vanilla/tr_surface.cpp
@@ -1622,22 +1622,22 @@ void RB_SurfaceEntity( surfaceType_t *surfType ) {
break;
case RT_ENT_CHAIN:
{
- int i, count, start;
- static trRefEntity_t tempEnt = *backEnd.currentEntity;
+ static trRefEntity_t tempEnt = *backEnd.currentEntity;
+
//rww - if not static then currentEntity is garbage because
//this is a local. This was not static in sof2.. but I guess
//they never check ce.renderfx so it didn't show up.
- start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart;
- count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount;
+ const int start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart;
+ const int count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount;
assert(count > 0);
backEnd.currentEntity = &tempEnt;
assert(backEnd.currentEntity->e.renderfx >= 0);
- for(i=0;ie, &backEnd.refdef.miniEntities[start+i], sizeof(backEnd.refdef.miniEntities[start+i]));
+ backEnd.currentEntity->e = backEnd.refdef.entities[j].e;
assert(backEnd.currentEntity->e.renderfx >= 0);
diff --git a/shared/rd-rend2/tr_light.cpp b/shared/rd-rend2/tr_light.cpp
index f4700b2882..bfcea99c66 100644
--- a/shared/rd-rend2/tr_light.cpp
+++ b/shared/rd-rend2/tr_light.cpp
@@ -368,15 +368,6 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) {
// only do min lighting when there is no hdr light data
if (tr.hdrLighting != qtrue)
{
-#ifndef REND2_SP
- // bonus items and view weapons have a fixed minimum add
- if (1/*!r_hdr->integer*/) {
- // give everything a minimum light add
- ent->ambientLight[0] += tr.identityLight * 32;
- ent->ambientLight[1] += tr.identityLight * 32;
- ent->ambientLight[2] += tr.identityLight * 32;
- }
-
if (ent->e.renderfx & RF_MINLIGHT)
{ //the minlight flag is now for items rotating on their holo thing
if (ent->e.shaderRGBA[0] == 255 &&
@@ -394,9 +385,8 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) {
ent->ambientLight[2] += tr.identityLight * 150;
}
}
-#else
// bonus items and view weapons have a fixed minimum add
- if (ent->e.renderfx & RF_MORELIGHT) {
+ else if (ent->e.renderfx & RF_MORELIGHT) {
ent->ambientLight[0] += tr.identityLight * 96;
ent->ambientLight[1] += tr.identityLight * 96;
ent->ambientLight[2] += tr.identityLight * 96;
@@ -407,7 +397,6 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) {
ent->ambientLight[1] += tr.identityLight * 32;
ent->ambientLight[2] += tr.identityLight * 32;
}
-#endif
}
d = VectorLength( ent->directedLight );
diff --git a/shared/rd-rend2/tr_local.h b/shared/rd-rend2/tr_local.h
index 15a4731749..80745ea1a5 100644
--- a/shared/rd-rend2/tr_local.h
+++ b/shared/rd-rend2/tr_local.h
@@ -2664,12 +2664,16 @@ struct glconfigExt_t
{
glconfig_t *glConfig;
+ qboolean textureFilterAnisotropicAvailable;
+ qboolean doGammaCorrectionWithShaders;
+ qboolean doStencilShadowsInOneDrawcall;
const char *originalExtensionString;
};
extern backEndState_t backEnd;
extern trGlobals_t tr;
extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init
+extern glconfigExt_t glConfigExt;
extern glRefConfig_t glRefConfig;
extern window_t window;
@@ -3328,9 +3332,7 @@ void R_InitNextFrame( void );
void RE_ClearScene( void );
void RE_AddRefEntityToScene( const refEntity_t *ent );
-#ifndef REND2_SP
void RE_AddMiniRefEntityToScene( const miniRefEntity_t *miniRefEnt );
-#endif
void RE_AddPolyToScene(qhandle_t hShader, int numVerts, const polyVert_t *verts, int num = 1);
void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );
void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
diff --git a/shared/rd-rend2/tr_main.cpp b/shared/rd-rend2/tr_main.cpp
index c445a45a96..958e5502e2 100644
--- a/shared/rd-rend2/tr_main.cpp
+++ b/shared/rd-rend2/tr_main.cpp
@@ -2003,7 +2003,6 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int
}
}
break;
-#ifndef REND2_SP
case RT_ENT_CHAIN:
shader = R_GetShaderByHandle(ent->e.customShader);
R_AddDrawSurf(
@@ -2015,7 +2014,6 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int
R_IsPostRenderEntity(ent),
0 /* cubeMap */ );
break;
-#endif
default:
ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" );
}
@@ -2633,9 +2631,7 @@ qboolean R_AddPortalView(const trRefdef_t *refdef)
case RT_ORIENTED_QUAD:
case RT_ELECTRICITY:
case RT_LINE:
-#ifndef REND2_SP
case RT_ORIENTEDLINE:
-#endif
case RT_CYLINDER:
case RT_SABER_GLOW:
break;
@@ -2682,10 +2678,8 @@ qboolean R_AddPortalView(const trRefdef_t *refdef)
}
}
break;
-#ifndef REND2_SP
case RT_ENT_CHAIN:
break;
-#endif
default:
break;
}
diff --git a/shared/rd-rend2/tr_scene.cpp b/shared/rd-rend2/tr_scene.cpp
index 3107d594b3..672505aac7 100644
--- a/shared/rd-rend2/tr_scene.cpp
+++ b/shared/rd-rend2/tr_scene.cpp
@@ -211,7 +211,13 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) {
}
return;
}
- if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) {
+
+ if (ent->reType == RT_ENT_CHAIN)
+ { //minirefents must die.
+ return;
+ }
+
+ if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_SP_REF_ENTITY_TYPE || ent->reType == RT_MAX_MP_REF_ENTITY_TYPE ) {
ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType );
}
diff --git a/shared/rd-rend2/tr_surface.cpp b/shared/rd-rend2/tr_surface.cpp
index 63443be5e7..5ca4ae638e 100644
--- a/shared/rd-rend2/tr_surface.cpp
+++ b/shared/rd-rend2/tr_surface.cpp
@@ -860,7 +860,6 @@ static void DoLine2(const vec3_t start, const vec3_t end, const vec3_t up, float
tess.indexes[tess.numIndexes++] = vbase + 3;
}
-#ifndef REND2_SP
static void DoLine_Oriented( const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth )
{
float spanWidth2;
@@ -921,7 +920,6 @@ static void RB_SurfaceOrientedLine(void)
VectorCopy(e->axis[1], right);
DoLine_Oriented(start, end, right, e->data.line.width*0.5);
}
-#endif
//-----------------
// RB_SurfaceLine
@@ -2010,7 +2008,6 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) {
}
}
-#ifdef REND2_SP
#define LATHE_SEG_STEP 10
#define BEZIER_STEP 0.05f // must be in the range of 0 to 1
@@ -2336,7 +2333,6 @@ static void RB_SurfaceClouds()
}
}
}
-#endif
/*
===========================================================================
@@ -2406,7 +2402,6 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) {
case RT_CYLINDER:
RB_SurfaceCylinder();
break;
-#ifndef REND2_SP
case RT_ORIENTEDLINE:
RB_SurfaceOrientedLine();
break;
@@ -2434,14 +2429,12 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) {
}
}
break;
-#else
case RT_LATHE:
RB_SurfaceLathe();
break;
case RT_CLOUDS:
RB_SurfaceClouds();
break;
-#endif
default:
RB_SurfaceAxis();
break;