]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added 3 optional parameters to the csqc R_AddDynamicLight builtin
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 12 Mar 2008 00:05:31 +0000 (00:05 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 12 Mar 2008 00:05:31 +0000 (00:05 +0000)
(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

clvm_cmds.c
todo

index e43ce8942943368d9a3d2c245ddd0db592c2ed4f..6c8c47ed6a6174109224aa6d8ba480d955d367a2 100644 (file)
@@ -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 93c5c0a26afc71349ea5ce7d110a13bb2871cfa6..60b61ae58b97eb8b801388489b6f185defcb0400 100644 (file)
--- 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)