r_refdef.scene.numlights = 0;
// restore the view settings to the values that VM_CL_UpdateView received from the client code
r_refdef.view = csqc_original_r_refdef_view;
+ // polygonbegin without draw2d arg has to guess
+ prog->polygonbegin_guess2d = false;
VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
extern cvar_t cl_bob;
extern cvar_t cl_bobcycle;
extern cvar_t cl_bobup;
-int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int tagindex, prvm_vec_t *shadingorigin)
+int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int tagindex, prvm_vec_t *returnshadingorigin)
{
int ret;
int attachloop;
matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
dp_model_t *model;
+ vec3_t shadingorigin;
*out = identitymatrix; // warnings and errors return identical matrix
*/
// return the origin of the view
- if (shadingorigin)
- Matrix4x4_OriginFromMatrix(&r_refdef.view.matrix, shadingorigin);
+ Matrix4x4_OriginFromMatrix(&r_refdef.view.matrix, shadingorigin);
}
else
{
// return the origin of the root entity in the chain
- if (shadingorigin)
- Matrix4x4_OriginFromMatrix(out, shadingorigin);
+ Matrix4x4_OriginFromMatrix(out, shadingorigin);
}
+ if (returnshadingorigin)
+ VectorCopy(shadingorigin, returnshadingorigin);
return 0;
}
// --blub
static void VM_CL_R_RenderScene (prvm_prog_t *prog)
{
+ qboolean ismain = r_refdef.view.ismain;
double t = Sys_DirtyTime();
VM_SAFEPARMCOUNT(0, VM_CL_R_RenderScene);
// update the views
- if(r_refdef.view.ismain)
+ if(ismain)
{
// set the main view
csqc_main_r_refdef_view = r_refdef.view;
-
- // clear the flags so no other view becomes "main" unless CSQC sets VF_MAINVIEW
- r_refdef.view.ismain = false;
- csqc_original_r_refdef_view.ismain = false;
}
// we need to update any RENDER_VIEWMODEL entities at this point because
// callprofile fixing hack: do not include this time in what is counted for CSQC_UpdateView
t = Sys_DirtyTime() - t;if (t < 0 || t >= 1800) t = 0;
prog->functions[PRVM_clientfunction(CSQC_UpdateView)].totaltime -= t;
+
+ // polygonbegin without draw2d arg has to guess
+ prog->polygonbegin_guess2d = false;
+
+ // update the views
+ if (ismain)
+ {
+ // clear the flags so no other view becomes "main" unless CSQC sets VF_MAINVIEW
+ r_refdef.view.ismain = false;
+ csqc_original_r_refdef_view.ismain = false;
+ }
}
//void(string texturename, float flag[, float is2d]) R_BeginPolygon
texname = PRVM_G_STRING(OFS_PARM0);
drawflags = (int)PRVM_G_FLOAT(OFS_PARM1);
- // weird hacky way to figure out if this is a 2D HUD polygon or a scene polygon
- draw2d = (prog->argc >= 3 ? (int)PRVM_G_FLOAT(OFS_PARM2) : r_refdef.draw2dstage);
+ if (prog->argc >= 3)
+ draw2d = PRVM_G_FLOAT(OFS_PARM2) != 0;
+ else
+ {
+ // weird hacky way to figure out if this is a 2D HUD polygon or a scene
+ // polygon, for compatibility with mods aimed at old darkplaces versions
+ // - polygonbegin_guess2d is 0 if the most recent major call was
+ // clearscene, 1 if the most recent major call was drawpic (and similar)
+ // or renderscene
+ draw2d = prog->polygonbegin_guess2d;
+ }
// we need to remember whether this is a 2D or 3D mesh we're adding to
mod = draw2d ? CL_Mesh_UI() : CL_Mesh_CSQC();
{
VM_Cmd_Init(prog);
prog->polygonbegin_model = NULL;
+ prog->polygonbegin_guess2d = 0;
}
void CLVM_reset_cmd(prvm_prog_t *prog)
World_End(&cl.world);
VM_Cmd_Reset(prog);
prog->polygonbegin_model = NULL;
+ prog->polygonbegin_guess2d = 0;
}