From a322a175de9498427ed3557b2ce18cb1162bd67c Mon Sep 17 00:00:00 2001 From: Eukara Date: Fri, 25 Dec 2020 03:07:07 +0000 Subject: [PATCH] Add support for the FIRSTPERSON renderflag from Q3 git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5794 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_ui.c | 5 ++--- engine/client/pr_csqc.c | 2 ++ engine/common/pr_common.h | 2 +- engine/common/protocol.h | 3 ++- engine/gl/gl_alias.c | 2 ++ engine/server/pr_cmds.c | 1 + 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/engine/client/cl_ui.c b/engine/client/cl_ui.c index 0539debd5..578727a66 100644 --- a/engine/client/cl_ui.c +++ b/engine/client/cl_ui.c @@ -453,9 +453,8 @@ void VQ3_AddEntity(const q3refEntity_t *q3) ent.forcedshader = VM_FROMSHANDLE(q3->customShader); ent.shaderTime = q3->shaderTime; - /* no, these flags are not alike, the first_person rf in q3a so mirrors don't draw them -eukara */ - /*if (q3->renderfx & Q3RF_FIRST_PERSON) - ent.flags |= RF_WEAPONMODEL;*/ + if (q3->renderfx & Q3RF_FIRST_PERSON) + ent.flags |= RF_FIRSTPERSON; if (q3->renderfx & Q3RF_DEPTHHACK) ent.flags |= RF_DEPTHHACK; if (q3->renderfx & Q3RF_THIRD_PERSON) diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 1ecfc7ab0..6ec01dd93 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -842,6 +842,8 @@ static qboolean CopyCSQCEdictToEntity(csqcedict_t *fte_restrict in, entity_t *ft } if (rflags & CSQCRF_EXTERNALMODEL) out->flags |= RF_EXTERNALMODEL; + if (rflags & CSQCRF_FIRSTPERSON) + out->flags |= RF_FIRSTPERSON; if (rflags & CSQCRF_DEPTHHACK) out->flags |= RF_DEPTHHACK; if (rflags & CSQCRF_ADDITIVE) diff --git a/engine/common/pr_common.h b/engine/common/pr_common.h index ce120db3d..a80dbe28d 100644 --- a/engine/common/pr_common.h +++ b/engine/common/pr_common.h @@ -811,12 +811,12 @@ typedef enum #define CSQCRF_USEAXIS 16 //use v_forward/v_right/v_up as an axis/matrix - predraw is needed to use this properly #define CSQCRF_NOSHADOW 32 //don't cast shadows upon other entities (can still be self shadowing, if the engine wishes, and not additive) #define CSQCRF_FRAMETIMESARESTARTTIMES 64 //EXT_CSQC_1: frame times should be read as (time-frametime). +#define CSQCRF_FIRSTPERSON 1024 //drawn ONLY in mirrors //#define CSQCRFDP_USETRANSPARENTOFFSET 64 // Allows QC to customize origin used for transparent sorting via transparent_origin global, helps to fix transparent sorting bugs on a very large entities ////#define CSQCRF_NOAUTOADD 128 // removed in favour of predraw return values. //#define CSQCRFDP_WORLDOBJECT 128 // for large outdoor entities that should not be culled. //#define CSQCRFDP_FULLBRIGHT 256 //#define CSQCRFDP_NOSHADOW 512 -//#define CSQCRF_UNUSED 1024 //#define CSQCRF_UNUSED 2048 //#define CSQCRFDP_MODELLIGHT 4096 // CSQC-set model light //#define CSQCRFDP_DYNAMICMODELLIGHT 8192 // origin-dependent model light diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 5b6cd245b..4551cb011 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -1357,7 +1357,8 @@ typedef struct q1usercmd_s #define RF_NOSHADOW (1u<<20) //disables shadow casting #define RF_NODEPTHTEST (1u<<21) //forces shader sort order and BEF_FORCENODEPTH #define RF_FORCECOLOURMOD (1u<<22) //forces BEF_FORCECOLOURMOD -#define RF_WEAPONMODELNOBOB (1u<<23) // +#define RF_WEAPONMODELNOBOB (1u<<23) +#define RF_FIRSTPERSON (1u<<24) //only draw through eyes // player_state_t->refdef flags #define RDF_UNDERWATER (1u<<0) // warp the screen as apropriate (fov trick) diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index 8167fee98..3e75c8ce6 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -2855,6 +2855,8 @@ void BE_GenModelBatches(batch_t **batches, const dlight_t *dl, unsigned int bemo { ent = &cl_visedicts[i]; + if ((r_refdef.externalview && (ent->flags & RF_FIRSTPERSON)) || chase_active.ival) + continue; if (!r_refdef.externalview && (ent->flags & RF_EXTERNALMODEL) && !chase_active.ival) continue; diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 8416f9017..b017dddb9 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -13239,6 +13239,7 @@ void PR_DumpPlatform_f(void) {"RF_USEAXIS", "const float", CS, D("The entity will be oriented according to the current v_forward+v_right+v_up vector values instead of the entity's .angles field."), CSQCRF_USEAXIS}, {"RF_NOSHADOW", "const float", CS, D("This entity will not cast shadows. Often useful on view models."), CSQCRF_NOSHADOW}, {"RF_FRAMETIMESARESTARTTIMES","const float", CS, D("Specifies that the frame1time, frame2time field are timestamps (denoting the start of the animation) rather than time into the animation."), CSQCRF_FRAMETIMESARESTARTTIMES}, + {"RF_FIRSTPERSON","const float", CS, D("This is basically the opposite of RF_EXTERNALMODEL. Don't draw in third-person or mirrors."), CSQCRF_FIRSTPERSON}, {"IE_KEYDOWN", "const float", CS|MENU, D("Specifies that a key was pressed. Second argument is the scan code. Third argument is the unicode (printable) char value. Fourth argument denotes which keyboard(or mouse, if its a mouse 'scan' key) the event came from. Note that some systems may completely separate scan codes and unicode values, with a 0 value for the unspecified argument."), CSIE_KEYDOWN}, {"IE_KEYUP", "const float", CS|MENU, D("Specifies that a key was released. Arguments are the same as IE_KEYDOWN. On some systems, this may be fired instantly after IE_KEYDOWN was fired."), CSIE_KEYUP},