+#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();
+}
+