From 2007ef0f902e5738e83f9187db16765a9d7383d5 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 27 Mar 2024 09:04:59 +0100 Subject: [PATCH] Added missing z_index parameter to VertexLights2DServer::sample_light(). --- .../doc_classes/VertexLights2DServer.xml | 1 + modules/vertex_lights_2d/vertex_light_data.cpp | 10 ++++++---- modules/vertex_lights_2d/vertex_lights_2d_server.cpp | 8 ++++---- modules/vertex_lights_2d/vertex_lights_2d_server.h | 6 +++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/modules/vertex_lights_2d/doc_classes/VertexLights2DServer.xml b/modules/vertex_lights_2d/doc_classes/VertexLights2DServer.xml index 579e2ae2b..f1f41ed3d 100644 --- a/modules/vertex_lights_2d/doc_classes/VertexLights2DServer.xml +++ b/modules/vertex_lights_2d/doc_classes/VertexLights2DServer.xml @@ -245,6 +245,7 @@ + Sample the lighing information at a specific position. diff --git a/modules/vertex_lights_2d/vertex_light_data.cpp b/modules/vertex_lights_2d/vertex_light_data.cpp index 7703ffe65..8c9b397c9 100644 --- a/modules/vertex_lights_2d/vertex_light_data.cpp +++ b/modules/vertex_lights_2d/vertex_light_data.cpp @@ -39,7 +39,7 @@ void VertexLights2DServer::VertexLightQuadrant2D::get_lights(Listz_range.x || p_z_index > l->z_range.y) { + continue; + } Vector2 light_to_pos = p_position - l->position; @@ -185,7 +187,7 @@ void VertexLights2DServer::VertexLightMap2D::clear() { } } -Color VertexLights2DServer::VertexLightMap2D::sample_light(const Vector2 &p_position, const int p_item_cull_mask, const int p_layer) { +Color VertexLights2DServer::VertexLightMap2D::sample_light(const Vector2 &p_position, const int p_item_cull_mask, const int p_layer, const int p_z_index) { Color c = base_color; Vector2i quadrant_position = to_quadrant_position(p_position); @@ -197,7 +199,7 @@ Color VertexLights2DServer::VertexLightMap2D::sample_light(const Vector2 &p_posi if (quadrants.has(qp)) { VertexLightQuadrant2D *q = quadrants[qp]; - c = q->sample_light(c, p_position, p_item_cull_mask, p_layer); + c = q->sample_light(c, p_position, p_item_cull_mask, p_layer, p_z_index); } } } diff --git a/modules/vertex_lights_2d/vertex_lights_2d_server.cpp b/modules/vertex_lights_2d/vertex_lights_2d_server.cpp index cc046839f..e514ddd18 100644 --- a/modules/vertex_lights_2d/vertex_lights_2d_server.cpp +++ b/modules/vertex_lights_2d/vertex_lights_2d_server.cpp @@ -294,11 +294,11 @@ void VertexLights2DServer::light_set_item_cull_mask(RID p_light, const int p_ite // Sampling -Color VertexLights2DServer::sample_light(RID p_map, const Vector2 &p_position, const int p_item_cull_mask, const int p_layer) { +Color VertexLights2DServer::sample_light(RID p_map, const Vector2 &p_position, const int p_item_cull_mask, const int p_layer, const int p_z_index) { VertexLightMap2D *map = map_owner.getornull(p_map); ERR_FAIL_COND_V(map == NULL, Color()); - return map->sample_light(p_position, p_item_cull_mask, p_layer); + return map->sample_light(p_position, p_item_cull_mask, p_layer, p_z_index); } // Rest @@ -432,9 +432,9 @@ void VertexLights2DServer::_bind_methods() { // Sampling - ClassDB::bind_method(D_METHOD("sample_light", "map", "position", "item_cull_mask", "layer"), &VertexLights2DServer::sample_light, DEFVAL(1), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("sample_light", "map", "position", "item_cull_mask", "layer", "z_index"), &VertexLights2DServer::sample_light, DEFVAL(1), DEFVAL(0), DEFVAL(0)); - // Rest + // Rest, DEFVAL(0) ClassDB::bind_method(D_METHOD("free", "rid"), &VertexLights2DServer::free); diff --git a/modules/vertex_lights_2d/vertex_lights_2d_server.h b/modules/vertex_lights_2d/vertex_lights_2d_server.h index 6a85e48e1..854b848ff 100644 --- a/modules/vertex_lights_2d/vertex_lights_2d_server.h +++ b/modules/vertex_lights_2d/vertex_lights_2d_server.h @@ -108,7 +108,7 @@ public: // Sampling - Color sample_light(RID p_map, const Vector2 &p_position, const int p_item_cull_mask = 1, const int p_layer = 0); + Color sample_light(RID p_map, const Vector2 &p_position, const int p_item_cull_mask = 1, const int p_layer = 0, const int p_z_index = 0); // Rest @@ -175,7 +175,7 @@ protected: void get_lights(List *p_lights); - Color sample_light(const Color &p_current_color, const Vector2 &p_local_position, const int p_item_cull_mask, const int p_layer); + Color sample_light(const Color &p_current_color, const Vector2 &p_local_position, const int p_item_cull_mask, const int p_layer, const int p_z_index); VertexLightQuadrant2D() { map = NULL; @@ -203,7 +203,7 @@ protected: void clear(); - Color sample_light(const Vector2 &p_position, const int p_item_cull_mask = 1, const int p_layer = 0); + Color sample_light(const Vector2 &p_position, const int p_item_cull_mask = 1, const int p_layer = 0, const int p_z_index = 0); _FORCE_INLINE_ Vector2i to_quadrant_position(const Vector2 &p_position) { return Vector2i(p_position.x / quadrant_size.x, p_position.y / quadrant_size.y);