Make Light2D respect CanvasLayer layer_min and layer_max
As the masked light list takes no account of layer_min and layer_max, the canvas_layed_id is passed to the _light_mask_canvas_items function where it can be used to reject lights outside the layer range.
This commit is contained in:
parent
f108037cbf
commit
1b5c4bc5b7
3 changed files with 9 additions and 11 deletions
|
@ -204,10 +204,7 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor
|
|||
}
|
||||
}
|
||||
|
||||
void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights) {
|
||||
|
||||
if (!p_masked_lights)
|
||||
return;
|
||||
void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights, int p_canvas_layer_id) {
|
||||
|
||||
RasterizerCanvas::Item *ci = p_canvas_item;
|
||||
|
||||
|
@ -216,7 +213,7 @@ void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Ite
|
|||
RasterizerCanvas::Light *light = p_masked_lights;
|
||||
while (light) {
|
||||
|
||||
if (ci->light_mask & light->item_mask && p_z >= light->z_min && p_z <= light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) {
|
||||
if ((p_canvas_layer_id >= light->layer_min) && (p_canvas_layer_id <= light->layer_max) && (ci->light_mask & light->item_mask) && (p_z >= light->z_min) && (p_z <= light->z_max) && (ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache))) {
|
||||
ci->light_masked = true;
|
||||
}
|
||||
|
||||
|
@ -227,7 +224,7 @@ void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Ite
|
|||
}
|
||||
}
|
||||
|
||||
void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) {
|
||||
void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect, int p_canvas_layer_id) {
|
||||
|
||||
VSG::canvas_render->canvas_begin();
|
||||
|
||||
|
@ -267,7 +264,7 @@ void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_tr
|
|||
continue;
|
||||
|
||||
if (p_masked_lights) {
|
||||
_light_mask_canvas_items(VS::CANVAS_ITEM_Z_MIN + i, z_list[i], p_masked_lights);
|
||||
_light_mask_canvas_items(VS::CANVAS_ITEM_Z_MIN + i, z_list[i], p_masked_lights, p_canvas_layer_id);
|
||||
}
|
||||
|
||||
VSG::canvas_render->canvas_render_items(z_list[i], VS::CANVAS_ITEM_Z_MIN + i, p_canvas->modulate, p_lights, p_transform);
|
||||
|
|
|
@ -159,13 +159,13 @@ public:
|
|||
private:
|
||||
void _render_canvas_item_tree(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights);
|
||||
void _render_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner);
|
||||
void _light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights);
|
||||
void _light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights, int p_canvas_layer_id);
|
||||
|
||||
RasterizerCanvas::Item **z_list;
|
||||
RasterizerCanvas::Item **z_last_list;
|
||||
|
||||
public:
|
||||
void render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect);
|
||||
void render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect, int p_canvas_layer_id);
|
||||
|
||||
RID canvas_create();
|
||||
void canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring);
|
||||
|
|
|
@ -229,15 +229,16 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
|
|||
RasterizerCanvas::Light *canvas_lights = NULL;
|
||||
|
||||
RasterizerCanvas::Light *ptr = lights;
|
||||
int canvas_layer_id = E->get()->layer;
|
||||
while (ptr) {
|
||||
if (E->get()->layer >= ptr->layer_min && E->get()->layer <= ptr->layer_max) {
|
||||
if (canvas_layer_id >= ptr->layer_min && canvas_layer_id <= ptr->layer_max) {
|
||||
ptr->next_ptr = canvas_lights;
|
||||
canvas_lights = ptr;
|
||||
}
|
||||
ptr = ptr->filter_next_ptr;
|
||||
}
|
||||
|
||||
VSG::canvas->render_canvas(canvas, xform, canvas_lights, lights_with_mask, clip_rect);
|
||||
VSG::canvas->render_canvas(canvas, xform, canvas_lights, lights_with_mask, clip_rect, canvas_layer_id);
|
||||
i++;
|
||||
|
||||
if (scenario_draw_canvas_bg && E->key().get_layer() >= scenario_canvas_max_layer) {
|
||||
|
|
Loading…
Reference in a new issue