diff --git a/include/QF/scene/scene.h b/include/QF/scene/scene.h index 5100a652e..f6ef15c0e 100644 --- a/include/QF/scene/scene.h +++ b/include/QF/scene/scene.h @@ -52,6 +52,7 @@ enum scene_components { scene_light, scene_efrags, scene_lightstyle, + scene_lightleaf, scene_lightid, //FIXME these should probably be private to the sw renderer (and in a diff --git a/libs/scene/light.c b/libs/scene/light.c index 45e862e22..09c6b3c21 100644 --- a/libs/scene/light.c +++ b/libs/scene/light.c @@ -100,17 +100,22 @@ Light_AddLight (lightingdata_t *ldata, const light_t *light, int style) set_t _pvs = SET_STATIC_INIT (model->brush.visleafs, alloca); set_t *pvs = &_pvs; + uint32_t leafnum = ~0u; if (light->position[3]) { // positional light mleaf_t *leaf = Mod_PointInLeaf (light->position, &model->brush); Mod_LeafPVS_set (leaf, &model->brush, 0, pvs); + leafnum = leaf - model->brush.leafs; } else if (DotProduct (light->direction, light->direction)) { // directional light (sun) pvs = ldata->sun_pvs; + leafnum = 0; } else { // ambient light - Mod_LeafPVS_set (model->brush.leafs, &model->brush, 0, pvs); + Mod_LeafPVS_set (model->brush.leafs, &model->brush, 0xff, pvs); } + Ent_SetComponent (ent.id, scene_lightleaf, ent.reg, &leafnum); + efrag_t *efrags = 0; efrag_t **lastlink = &efrags; for (auto li = set_first (pvs); li; li = set_next (li)) { diff --git a/libs/scene/scene.c b/libs/scene/scene.c index 3422a5b9d..47eb27e1b 100644 --- a/libs/scene/scene.c +++ b/libs/scene/scene.c @@ -166,6 +166,10 @@ static const component_t scene_components[scene_comp_count] = { .size = sizeof (int), .name = "lightstyle", }, + [scene_lightleaf] = { + .size = sizeof (uint32_t), + .name = "lightleaf", + }, [scene_lightid] = { .size = sizeof (uint32_t), .name = "lightid",