void V_DriftPitch(void);
void V_FadeViewFlashs(void);
void V_CalcViewBlend(void);
-void V_CalcRefdefUsing(const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump);
+void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump, float clstatsviewheight);
void V_CalcRefdef(void);
void CL_Locs_Reload_f(void);
}
//#347 void() runstandardplayerphysics (EXT_CSQC)
-#define PMF_JUMP_HELD 1
-#define PMF_LADDER 2 // not used by DP
-#define PMF_DUCKED 4 // FIXME FTEQW doesn't have this for Q1 like movement
+#define PMF_JUMP_HELD 1 // matches FTEQW
+#define PMF_LADDER 2 // not used by DP, FTEQW sets this in runplayerphysics but does not read it
+#define PMF_DUCKED 4 // FIXME FTEQW doesn't have this for Q1 like movement because Q1 cannot crouch
+#define PMF_ONGROUND 8 // FIXME FTEQW doesn't have this for Q1 like movement and expects CSQC code to do its own trace, this is stupid CPU waste
static void VM_CL_runplayerphysics (prvm_prog_t *prog)
{
cl_clientmovement_state_t s;
VectorCopy(s.velocity, PRVM_clientedictvector(ent, velocity));
PRVM_clientedictfloat(ent, pmove_flags) =
(s.crouched ? PMF_DUCKED : 0) |
- (s.cmd.canjump ? 0 : PMF_JUMP_HELD);
+ (s.cmd.canjump ? 0 : PMF_JUMP_HELD) |
+ (s.onground ? PMF_ONGROUND : 0);
}
//#348 string(float playernum, string keyname) getplayerkeyvalue (EXT_CSQC)
R_GetCubemap(name);
}
+#define REFDEFFLAG_TELEPORTED 1
+#define REFDEFFLAG_JUMPING 2
+static void VM_CL_V_CalcRefdef(prvm_prog_t *prog)
+{
+ matrix4x4_t entrendermatrix;
+ vec3_t clviewangles;
+ qboolean teleported;
+ qboolean clonground;
+ qboolean clcmdjump;
+ float clstatsviewheight;
+ prvm_edict_t *ent;
+ int flags;
+
+ VM_SAFEPARMCOUNT(2, VM_CL_V_CalcRefdef);
+ ent = PRVM_G_EDICT(OFS_PARM0);
+ flags = PRVM_G_FLOAT(OFS_PARM1);
+
+ // use the CL_GetTagMatrix function on self to ensure consistent behavior (duplicate code would be bad)
+ CL_GetTagMatrix(prog, &entrendermatrix, ent, 0);
+
+ VectorCopy(cl.csqc_viewangles, clviewangles);
+ teleported = (flags & REFDEFFLAG_TELEPORTED) != 0;
+ clonground = ((int)PRVM_clientedictfloat(ent, pmove_flags) & PMF_ONGROUND) != 0;
+ clcmdjump = (flags & REFDEFFLAG_JUMPING) != 0;
+ clstatsviewheight = PRVM_clientedictvector(ent, view_ofs)[2];
+
+ V_CalcRefdefUsing(&entrendermatrix, clviewangles, teleported, clonground, clcmdjump, clstatsviewheight);
+
+ VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
+ VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
+ CSQC_R_RecalcView();
+}
+
//============================================================================
// To create a almost working builtin file from this replace:
NULL, // #637
VM_CL_RotateMoves, // #638
VM_digest_hex, // #639
-NULL, // #640
+VM_CL_V_CalcRefdef, // #640 void(entity e) V_CalcRefdef (DP_CSQC_V_CALCREFDEF)
+NULL, // #641
};
const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);
if(renderflags & RF_ADDITIVE) entrender->flags |= RENDER_ADDITIVE;
}
+ if(edictnum == CL_VM_GetViewEntity())
+ entrender->flags |= RENDER_EXTERIORMODEL;
+
c = (int)PRVM_clientedictfloat(ed, colormap);
if (c <= 0)
CL_SetEntityColormapColors(entrender, -1);
return ret;
}
+
+int CL_VM_GetViewEntity(void)
+{
+ if(cl.csqc_server2csqcentitynumber[cl.viewentity])
+ return cl.csqc_server2csqcentitynumber[cl.viewentity];
+ return cl.viewentity;
+}
dp_model_t *CL_GetModelByIndex(int modelindex);
+int CL_VM_GetViewEntity(void);
+
#endif
const float VF_MINFPS_QUALITY = 213;
//use getproperty(VF_MINFPS_QUALITY); to do CSQC based LOD based on cl_minfps
//1 should lead to an unmodified view
+
+//DP_CSQC_V_CALCREFDEF_WIP1
+//idea: divVerent
+//darkplaces implementation: divVerent
+//builtin definitions:
+void(entity e, float refdefflags) V_CalcRefdef = #640;
+//constant definitions:
+float PMF_DUCKED = 4;
+float PMF_ONGROUND = 8;
+float REFDEFFLAG_TELEPORTED = 1;
+float REFDEFFLAG_JUMPING = 2;
+//- use this on the player entity after performing prediction
+//- pass REFDEFFLAG_TELEPORTED if the player teleported since last frame
+//- pass REFDEFFLAG_JUMPING if jump button is pressed
+//- the player entity needs to have origin, velocity, pmove_flags set according
+// to prediction (the above two PMF_ flags are used in the player's pmove_flags)
+//- NOTE: to check for this, ALSO OR a check with DP_CSQC_V_CALCREFDEF to also support
+// the finished extension once done
}
// don't let monster sounds override player sounds
- if (ch->entnum == cl.viewentity && entnum != cl.viewentity)
+ if ((ch->entnum == cl.viewentity || ch->entnum == CL_VM_GetViewEntity()) && !(entnum == cl.viewentity || entnum == CL_VM_GetViewEntity()))
continue;
// don't override looped sounds
// anything coming from the view entity will always be full volume
// LordHavoc: make sounds with ATTN_NONE have no spatialization
- if (ch->entnum == cl.viewentity || ch->distfade == 0)
+ if (ch->entnum == cl.viewentity || ch->entnum == CL_VM_GetViewEntity() || ch->distfade == 0)
{
ch->prologic_invert = 1;
if (snd_spatialization_prologic.integer != 0)
"DP_CSQC_QUERYRENDERENTITY "
"DP_CSQC_ROTATEMOVES "
"DP_CSQC_SETPAUSE "
+"DP_CSQC_V_CALCREFDEF_WIP1 "
"DP_EF_ADDITIVE "
"DP_EF_BLUE "
"DP_EF_DOUBLESIDED "
out[2] = highpass_limited(value[2], fracz, limitz, &store[2]);
}
-void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump)
+void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump, float clstatsviewheight)
{
float vieworg[3], viewangles[3], smoothtime;
float gunorg[3], gunangles[3];
// apply the viewofs (even if chasecam is used)
// Samual: Lets add smoothing for this too so that things like crouching are done with a transition.
viewheight = bound(0, (cl.time - cl.oldtime) / max(0.0001, cl_smoothviewheight.value), 1);
- viewheightavg = viewheightavg * (1 - viewheight) + cl.stats[STAT_VIEWHEIGHT] * viewheight;
+ viewheightavg = viewheightavg * (1 - viewheight) + clstatsviewheight * viewheight;
vieworg[2] += viewheightavg;
if (chase_active.value)
// ent is the view entity (visible when out of body)
ent = &cl.entities[cl.viewentity];
- V_CalcRefdefUsing(&ent->render.matrix, cl.viewangles, !ent->persistent.trail_allowed, cl.onground, cl.cmd.jump); // FIXME use a better way to detect teleport/warp than trail_allowed
+ V_CalcRefdefUsing(&ent->render.matrix, cl.viewangles, !ent->persistent.trail_allowed, cl.onground, cl.cmd.jump, cl.stats[STAT_VIEWHEIGHT]); // FIXME use a better way to detect teleport/warp than trail_allowed
}
else
{