S_StaticSound (s, f, PRVM_G_FLOAT(OFS_PARM2), PRVM_G_FLOAT(OFS_PARM3)*64);
}
-// #92 vector(vector org) getlight (DP_QC_GETLIGHT)
+// #92 vector(vector org[, float lpflag]) getlight (DP_QC_GETLIGHT)
static void VM_CL_getlight (void)
{
vec3_t ambientcolor, diffusecolor, diffusenormal;
vec_t *p;
- VM_SAFEPARMCOUNT(1, VM_CL_getlight);
+ VM_SAFEPARMCOUNTRANGE(1, 2, VM_CL_getlight);
p = PRVM_G_VECTOR(OFS_PARM0);
VectorClear(ambientcolor);
VectorClear(diffusecolor);
VectorClear(diffusenormal);
- if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
+ if (prog->argc >= 2)
+ R_CompleteLightPoint(ambientcolor, diffusecolor, diffusenormal, p, PRVM_G_FLOAT(OFS_PARM1));
+ else if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
cl.worldmodel->brush.LightPoint(cl.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
VectorMA(ambientcolor, 0.5, diffusecolor, PRVM_G_VECTOR(OFS_RETURN));
}
-
//============================================================================
//[515]: SCENE MANAGER builtins
extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed, int edictnum);//csprogs.c
=============================================================================
*/
-void R_CompleteLightPoint(vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal, const vec3_t p, qboolean dynamic, qboolean rtworld)
+void R_CompleteLightPoint(vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal, const vec3_t p, const int flags)
{
+ int i, numlights, flag;
+ float f, relativepoint[3], dist, dist2, lightradius2;
+ rtlight_t *light;
+ dlight_t *dlight;
+
VectorClear(diffusecolor);
VectorClear(diffusenormal);
- if (!r_fullbright.integer && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.LightPoint)
+ if (flags & LP_LIGHTMAP)
{
- ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = r_refdef.scene.ambient;
- r_refdef.scene.worldmodel->brush.LightPoint(r_refdef.scene.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
+ if (!r_fullbright.integer && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.LightPoint)
+ {
+ ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = r_refdef.scene.ambient;
+ r_refdef.scene.worldmodel->brush.LightPoint(r_refdef.scene.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
+ }
+ else
+ VectorSet(ambientcolor, 1, 1, 1);
}
- else
- VectorSet(ambientcolor, 1, 1, 1);
-
- if (dynamic)
+ if (flags & LP_RTWORLD)
{
- int i, numlights, flag;
- float f, relativepoint[3], dist, dist2, lightradius2;
- rtlight_t *light;
- dlight_t *dlight;
-
- // sample rtlights
- if (rtworld)
+ flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
+ numlights = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray);
+ for (i = 0; i < numlights; i++)
{
- flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
- numlights = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray);
- for (i = 0; i < numlights; i++)
- {
- dlight = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, i);
- if (!dlight)
- continue;
- light = &dlight->rtlight;
- if (!(light->flags & flag))
- continue;
- // sample
- lightradius2 = light->radius * light->radius;
- VectorSubtract(light->shadoworigin, p, relativepoint);
- dist2 = VectorLength2(relativepoint);
- if (dist2 >= lightradius2)
- continue;
- dist = sqrt(dist2) / light->radius;
- f = dist < 1 ? (r_shadow_lightintensityscale.value * ((1.0f - dist) * r_shadow_lightattenuationlinearscale.value / (r_shadow_lightattenuationdividebias.value + dist*dist))) : 0;
- if (f <= 0)
- continue;
- // todo: add to both ambient and diffuse
- if (!light->shadow || CL_TraceLine(p, light->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction == 1)
- VectorMA(ambientcolor, f, light->currentcolor, ambientcolor);
- }
+ dlight = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, i);
+ if (!dlight)
+ continue;
+ light = &dlight->rtlight;
+ if (!(light->flags & flag))
+ continue;
+ // sample
+ lightradius2 = light->radius * light->radius;
+ VectorSubtract(light->shadoworigin, p, relativepoint);
+ dist2 = VectorLength2(relativepoint);
+ if (dist2 >= lightradius2)
+ continue;
+ dist = sqrt(dist2) / light->radius;
+ f = dist < 1 ? (r_shadow_lightintensityscale.value * ((1.0f - dist) * r_shadow_lightattenuationlinearscale.value / (r_shadow_lightattenuationdividebias.value + dist*dist))) : 0;
+ if (f <= 0)
+ continue;
+ // todo: add to both ambient and diffuse
+ if (!light->shadow || CL_TraceLine(p, light->shadoworigin, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, true, false, NULL, false).fraction == 1)
+ VectorMA(ambientcolor, f, light->currentcolor, ambientcolor);
}
-
+ }
+ if (flags & LP_DYNLIGHT)
+ {
// sample dlights
for (i = 0;i < r_refdef.scene.numlights;i++)
{