mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-21 03:01:15 +00:00
[scene] Add a leaf component to lights
Regular leaf number for positional lights, 0 for directional, and ~0 for ambient.
This commit is contained in:
parent
2790972cb0
commit
123bf14784
3 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue