-static void R_UpdateEntityLighting(entity_render_t *ent)
-{
- vec3_t tempdiffusenormal;
-
- // fetch the lighting from the worldmodel data
- VectorSet(ent->modellight_ambient, r_ambient.value * (2.0f / 128.0f), r_ambient.value * (2.0f / 128.0f), r_ambient.value * (2.0f / 128.0f));
- VectorClear(ent->modellight_diffuse);
- VectorClear(tempdiffusenormal);
- if ((ent->flags & RENDER_LIGHT) && r_refdef.worldmodel && r_refdef.worldmodel->brush.LightPoint)
- {
- vec3_t org;
- Matrix4x4_OriginFromMatrix(&ent->matrix, org);
- r_refdef.worldmodel->brush.LightPoint(r_refdef.worldmodel, org, ent->modellight_ambient, ent->modellight_diffuse, tempdiffusenormal);
- }
- else // highly rare
- VectorSet(ent->modellight_ambient, 1, 1, 1);
-
- // move the light direction into modelspace coordinates for lighting code
- Matrix4x4_Transform3x3(&ent->inversematrix, tempdiffusenormal, ent->modellight_lightdir);
- if(VectorLength2(ent->modellight_lightdir) > 0)
- {
- VectorNormalize(ent->modellight_lightdir);
- }
- else
- {
- VectorSet(ent->modellight_lightdir, 0, 0, 1); // have to set SOME valid vector here
- }
-
- // scale ambient and directional light contributions according to rendering variables
- ent->modellight_ambient[0] *= ent->colormod[0] * r_refdef.lightmapintensity;
- ent->modellight_ambient[1] *= ent->colormod[1] * r_refdef.lightmapintensity;
- ent->modellight_ambient[2] *= ent->colormod[2] * r_refdef.lightmapintensity;
- ent->modellight_diffuse[0] *= ent->colormod[0] * r_refdef.lightmapintensity;
- ent->modellight_diffuse[1] *= ent->colormod[1] * r_refdef.lightmapintensity;
- ent->modellight_diffuse[2] *= ent->colormod[2] * r_refdef.lightmapintensity;
-}
-