X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=csprogs.c;h=f0a01a2678c783f94d639616de86621d4a62a0c9;hb=c045878e6948f00e52f17c9df6beefa2dfdfd868;hp=77b0daebec454f1f6b29e0270433871fb8bab89f;hpb=d090340b054029faddb432e2c66085e6e91abcf7;p=xonotic%2Fdarkplaces.git diff --git a/csprogs.c b/csprogs.c index 77b0daeb..f0a01a26 100644 --- a/csprogs.c +++ b/csprogs.c @@ -295,6 +295,7 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum) float scale; entity_render_t *entrender; dp_model_t *model; + prvm_vec3_t modellight_origin; model = CL_GetModelFromEdict(ed); if (!model) @@ -346,8 +347,10 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum) if (!VectorLength2(entrender->glowmod)) VectorSet(entrender->glowmod, 1, 1, 1); - // LordHavoc: use the CL_GetTagMatrix function on self to ensure consistent behavior (duplicate code would be bad) - CL_GetTagMatrix(prog, &entrender->matrix, ed, 0); + // LadyHavoc: use the CL_GetTagMatrix function on self to ensure consistent behavior (duplicate code would be bad) + // this also sets the custommodellight_origin for us + VectorCopy(modellight_origin, entrender->custommodellight_origin); + CL_GetTagMatrix(prog, &entrender->matrix, ed, 0, modellight_origin); // set up the animation data VM_GenerateFrameGroupBlend(prog, ed->priv.server->framegroupblend, ed); @@ -363,9 +366,9 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum) // model light if (renderflags & RF_MODELLIGHT) { - if (PRVM_clientedictvector(ed, modellight_ambient)) VectorCopy(PRVM_clientedictvector(ed, modellight_ambient), entrender->modellight_ambient); else VectorClear(entrender->modellight_ambient); - if (PRVM_clientedictvector(ed, modellight_diffuse)) VectorCopy(PRVM_clientedictvector(ed, modellight_diffuse), entrender->modellight_diffuse); else VectorClear(entrender->modellight_diffuse); - if (PRVM_clientedictvector(ed, modellight_dir)) VectorCopy(PRVM_clientedictvector(ed, modellight_dir), entrender->modellight_lightdir); else VectorClear(entrender->modellight_lightdir); + if (PRVM_clientedictvector(ed, modellight_ambient)) VectorCopy(PRVM_clientedictvector(ed, modellight_ambient), entrender->custommodellight_ambient); else VectorClear(entrender->custommodellight_ambient); + if (PRVM_clientedictvector(ed, modellight_diffuse)) VectorCopy(PRVM_clientedictvector(ed, modellight_diffuse), entrender->custommodellight_diffuse); else VectorClear(entrender->custommodellight_diffuse); + if (PRVM_clientedictvector(ed, modellight_dir)) VectorCopy(PRVM_clientedictvector(ed, modellight_dir), entrender->custommodellight_lightdir); else VectorClear(entrender->custommodellight_lightdir); entrender->flags |= RENDER_CUSTOMIZEDMODELLIGHT; } @@ -473,7 +476,6 @@ qboolean CL_VM_UpdateView (double frametime) return false; R_TimeReport("pre-UpdateView"); CSQC_BEGIN - r_refdef.view.ismain = true; csqc_original_r_refdef_view = r_refdef.view; csqc_main_r_refdef_view = r_refdef.view; //VectorCopy(cl.viewangles, oldangles); @@ -717,7 +719,7 @@ void CL_VM_UpdateShowingScoresState (int showingscores) CSQC_END } } -qboolean CL_VM_Event_Sound(int sound_num, float volume, int channel, float attenuation, int ent, vec3_t pos, int flags, float speed) +qboolean CL_VM_Event_Sound(int sound_num, float fvolume, int channel, float attenuation, int ent, vec3_t pos, int flags, float speed) { prvm_prog_t *prog = CLVM_prog; qboolean r = false; @@ -731,7 +733,7 @@ qboolean CL_VM_Event_Sound(int sound_num, float volume, int channel, float atten PRVM_G_FLOAT(OFS_PARM0) = ent; PRVM_G_FLOAT(OFS_PARM1) = CHAN_ENGINE2USER(channel); PRVM_G_INT(OFS_PARM2) = PRVM_SetTempString(prog, cl.sound_name[sound_num] ); - PRVM_G_FLOAT(OFS_PARM3) = volume; + PRVM_G_FLOAT(OFS_PARM3) = fvolume; PRVM_G_FLOAT(OFS_PARM4) = attenuation; VectorCopy(pos, PRVM_G_VECTOR(OFS_PARM5) ); PRVM_G_FLOAT(OFS_PARM6) = speed * 100.0f; @@ -1145,6 +1147,9 @@ void CL_VM_Init (void) // call the prog init prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Init), "QC function CSQC_Init is missing"); + // Once CSQC_Init was called, we consider csqc code fully initialized. + prog->inittime = realtime; + cl.csqc_loaded = true; cl.csqc_vidvars.drawcrosshair = false; @@ -1186,15 +1191,13 @@ qboolean CL_VM_GetEntitySoundOrigin(int entnum, vec3_t out) CSQC_BEGIN; - // FIXME consider attachments here! - ed = PRVM_EDICT_NUM(entnum - MAX_EDICTS); if(!ed->priv.required->free) { mod = CL_GetModelFromEdict(ed); VectorCopy(PRVM_clientedictvector(ed, origin), out); - if(CL_GetTagMatrix(prog, &matrix, ed, 0) == 0) + if(CL_GetTagMatrix(prog, &matrix, ed, 0, NULL) == 0) Matrix4x4_OriginFromMatrix(&matrix, out); if (mod && mod->soundfromcenter) VectorMAMAM(1.0f, out, 0.5f, mod->normalmins, 0.5f, mod->normalmaxs, out); @@ -1221,7 +1224,7 @@ qboolean CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clip if(PRVM_clientedictfunction(ed, camera_transform)) { ret = true; - if(viewmatrix || clipplane || visorigin) + if(viewmatrix && clipplane && visorigin) { Matrix4x4_ToVectors(viewmatrix, forward, left, up, origin); AnglesFromVectors(ang, forward, up, false); @@ -1242,7 +1245,7 @@ qboolean CL_VM_TransformView(int entnum, matrix4x4_t *viewmatrix, mplane_t *clip Matrix4x4_Invert_Full(&mat, viewmatrix); Matrix4x4_FromVectors(viewmatrix, forward, left, up, origin); Matrix4x4_Concat(&matq, viewmatrix, &mat); - Matrix4x4_TransformPositivePlane(&matq, clipplane->normal[0], clipplane->normal[1], clipplane->normal[2], clipplane->dist, &clipplane->normal[0]); + Matrix4x4_TransformPositivePlane(&matq, clipplane->normal[0], clipplane->normal[1], clipplane->normal[2], clipplane->dist, clipplane->normal_and_dist); } } CSQC_END