X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=clvm_cmds.c;h=e218878e200f86578cb4309304aeac5c6390291e;hb=9ac6f1395459b9ab4093f690365ce1e3d62d0577;hp=34baa67a4f9a637cebba8949235b548939359e12;hpb=de5bb2274041bd0ea98dae9a93419104b50b5465;p=xonotic%2Fdarkplaces.git diff --git a/clvm_cmds.c b/clvm_cmds.c index 34baa67a..e218878e 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -736,6 +736,8 @@ static void VM_CL_R_ClearScene (prvm_prog_t *prog) 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; @@ -2446,12 +2448,13 @@ static int CL_GetEntityLocalTagMatrix(prvm_prog_t *prog, prvm_edict_t *ent, int 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 @@ -2521,15 +2524,15 @@ int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int */ // 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; } @@ -3251,18 +3254,15 @@ static void VM_CL_GetEntity (prvm_prog_t *prog) // --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 @@ -3279,6 +3279,17 @@ static void VM_CL_R_RenderScene (prvm_prog_t *prog) // 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 @@ -3293,8 +3304,17 @@ static void VM_CL_R_PolygonBegin (prvm_prog_t *prog) 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(); @@ -4750,6 +4770,7 @@ void CLVM_init_cmd(prvm_prog_t *prog) { VM_Cmd_Init(prog); prog->polygonbegin_model = NULL; + prog->polygonbegin_guess2d = 0; } void CLVM_reset_cmd(prvm_prog_t *prog) @@ -4757,4 +4778,5 @@ void CLVM_reset_cmd(prvm_prog_t *prog) World_End(&cl.world); VM_Cmd_Reset(prog); prog->polygonbegin_model = NULL; + prog->polygonbegin_guess2d = 0; }