From: havoc Date: Wed, 12 Mar 2008 00:05:31 +0000 (+0000) Subject: added 3 optional parameters to the csqc R_AddDynamicLight builtin X-Git-Tag: xonotic-v0.1.0preview~2317 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fc1175dd677fc69eefa45ab30409091aa594be8b;p=xonotic%2Fdarkplaces.git added 3 optional parameters to the csqc R_AddDynamicLight builtin (style, cubemapname, pflags) and made it read v_forward, v_right, and v_up to orient the light (useful mainly with cubemaps), these can also (at least in DarkPlaces) be used as an alternative to radius (pass in radius = 1 if they are pre-scaled) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8209 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/clvm_cmds.c b/clvm_cmds.c index e43ce894..6c8c47ed 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -853,21 +853,54 @@ void VM_CL_R_SetView (void) PRVM_G_FLOAT(OFS_RETURN) = 1; } -//#305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC) +//#305 void(vector org, float radius, vector lightcolours[, float style, string cubemapname, float pflags]) adddynamiclight (EXT_CSQC) void VM_CL_R_AddDynamicLight (void) { - float *pos, *col; - matrix4x4_t matrix; - VM_SAFEPARMCOUNTRANGE(3, 3, VM_CL_R_AddDynamicLight); + vec_t *org; + float radius = 300; + vec_t *col; + int style = -1; + const char *cubemapname = NULL; + int pflags = PFLAGS_CORONA | PFLAGS_FULLDYNAMIC; + float coronaintensity = 1; + float coronasizescale = 0.25; + qboolean castshadow = true; + float ambientscale = 0; + float diffusescale = 1; + float specularscale = 1; + matrix4x4_t matrix; + vec3_t forward, left, up; + VM_SAFEPARMCOUNTRANGE(3, 8, VM_CL_R_AddDynamicLight); // if we've run out of dlights, just return if (r_refdef.scene.numlights >= MAX_DLIGHTS) return; - pos = PRVM_G_VECTOR(OFS_PARM0); + org = PRVM_G_VECTOR(OFS_PARM0); + radius = PRVM_G_FLOAT(OFS_PARM1); col = PRVM_G_VECTOR(OFS_PARM2); - Matrix4x4_CreateFromQuakeEntity(&matrix, pos[0], pos[1], pos[2], 0, 0, 0, PRVM_G_FLOAT(OFS_PARM1)); - R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &matrix, col, -1, NULL, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE); + if (prog->argc >= 4) + { + style = (int)PRVM_G_FLOAT(OFS_PARM3); + if (style >= MAX_LIGHTSTYLES) + { + Con_DPrintf("VM_CL_R_AddDynamicLight: out of bounds lightstyle index %i\n", style); + style = -1; + } + } + if (prog->argc >= 5) + cubemapname = PRVM_G_STRING(OFS_PARM4); + if (prog->argc >= 6) + pflags = (int)PRVM_G_FLOAT(OFS_PARM5); + coronaintensity = (pflags & PFLAGS_CORONA) != 0; + castshadow = (pflags & PFLAGS_NOSHADOW) == 0; + + VectorScale(prog->globals.client->v_forward, radius, forward); + VectorScale(prog->globals.client->v_right, -radius, left); + VectorScale(prog->globals.client->v_up, radius, up); + Matrix4x4_FromVectors(&matrix, forward, left, up, org); + + R_RTLight_Update(&r_refdef.scene.lights[r_refdef.scene.numlights++], false, &matrix, col, style, cubemapname, castshadow, coronaintensity, coronasizescale, ambientscale, diffusescale, specularscale, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE); } //============================================================================ diff --git a/todo b/todo index 93c5c0a2..60b61ae5 100644 --- a/todo +++ b/todo @@ -1,5 +1,6 @@ - todo: difficulty ratings are: 0 = trivial, 1 = easy, 2 = easy-moderate, 3 = moderate, 4 = moderate-hard, 5 = hard, 6 = hard++, 7 = nightmare, d = done, -d = done but have not notified the people who asked for it, f = failed, -f = failed but have not notified the people who asked for it 0 bug csqc client: darkplaces lacks prediction support +0 bug csqc: there is no WriteFloat, making ReadFloat useless (Urre) 0 bug darkplaces client csqc: engine prediction function is not implemented - could just return the engine's current cl.movement_origin (Spike) 0 bug darkplaces client csqc: entities not being drawn with VF_PERSPECTIVE 0? (daemon) 0 bug darkplaces client csqc: input queue functions needed for csqc prediction aren't implemented (Spike)