]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_cmds.c
implemented scissor rect clipping of lights in realtime lighting mode
[xonotic/darkplaces.git] / pr_cmds.c
index 2c1c8ce600e6b97fb58c27893dbe549162d755f3..7cf39ca5786d8f7aef93eca4d8bcb4989f292223 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -143,7 +143,7 @@ void PF_error (void)
 {
        char    *s;
        edict_t *ed;
-       
+
        s = PF_VarString(0);
        Con_Printf ("======SERVER ERROR in %s:\n%s\n", pr_strings + pr_xfunction->s_name, s);
        ed = PROG_TO_EDICT(pr_global_struct->self);
@@ -907,7 +907,7 @@ void PF_stuffcmd (void)
        if (entnum < 1 || entnum > svs.maxclients)
                Host_Error ("Parm 0 not a client");
        str = G_STRING(OFS_PARM1);      
-       
+
        old = host_client;
        host_client = &svs.clients[entnum-1];
        Host_ClientCommands ("%s", str);
@@ -943,7 +943,7 @@ void PF_cvar (void)
        char    *str;
        
        str = G_STRING(OFS_PARM0);
-       
+
        G_FLOAT(OFS_RETURN) = Cvar_VariableValue (str);
 }
 
@@ -1751,12 +1751,10 @@ void PF_WriteEntity (void)
 
 //=============================================================================
 
-int SV_ModelIndex (char *name);
-
 void PF_makestatic (void)
 {
-       edict_t *ent;
-       int             i, large;
+       edict_t *ent;
+       int i, large;
 
        ent = G_EDICT(OFS_PARM0);
 
@@ -2563,7 +2561,7 @@ void PF_getsurfacetexture(void)
                return;
        G_INT(OFS_RETURN) = surf->texinfo->texture->name - pr_strings;
 }
-//PF_getsurfacenearpoint, // #438 void(entity e, vector p) getsurfacenearpoint = #438;
+//PF_getsurfacenearpoint, // #438 float(entity e, vector p) getsurfacenearpoint = #438;
 void PF_getsurfacenearpoint(void)
 {
        int surfnum, best, modelindex;
@@ -2609,6 +2607,24 @@ void PF_getsurfacenearpoint(void)
        }
        G_FLOAT(OFS_RETURN) = best;
 }
+//PF_getsurfaceclippedpoint, // #439 vector(entity e, float s, vector p) getsurfaceclippedpoint = #439;
+void PF_getsurfaceclippedpoint(void)
+{
+       edict_t *ed;
+       msurface_t *surf;
+       vec3_t p, out;
+       VectorClear(G_VECTOR(OFS_RETURN));
+       ed = G_EDICT(OFS_PARM0);
+       if (!ed || ed->free)
+               return;
+       if (!(surf = getsurface(ed, G_FLOAT(OFS_PARM1))))
+               return;
+       // FIXME: implement rotation/scaling
+       VectorSubtract(G_VECTOR(OFS_PARM2), ed->v.origin, p);
+       clippointtosurface(surf, p, out);
+       // FIXME: implement rotation/scaling
+       VectorAdd(out, ed->v.origin, G_VECTOR(OFS_RETURN));
+}
 
 void PF_Fixme (void)
 {
@@ -2773,6 +2789,7 @@ PF_getsurfacepoint,     // #435 vector(entity e, float s, float n) getsurfacepoi
 PF_getsurfacenormal,    // #436 vector(entity e, float s) getsurfacenormal = #436;
 PF_getsurfacetexture,   // #437 string(entity e, float s) getsurfacetexture = #437;
 PF_getsurfacenearpoint, // #438 float(entity e, vector p) getsurfacenearpoint = #438;
+PF_getsurfaceclippedpoint,// #439 vector(entity e, float s, vector p) getsurfaceclippedpoint = #439;
 };
 
 builtin_t *pr_builtins = pr_builtin;