Set up transform notification for VertexLight2D.

This commit is contained in:
Relintai 2024-03-24 21:55:18 +01:00
parent 9ce6ebc1b5
commit 9df448113d
2 changed files with 17 additions and 5 deletions

View File

@ -83,12 +83,22 @@ VertexLight2D::VertexLight2D() {
_item_cull_mask = 1;
_z_range = Vector2i(-1024, 1024);
_mode = VERTEX_LIGHT_2D_MODE_ADD;
set_notify_transform(true);
}
VertexLight2D::~VertexLight2D() {
VertexLights2DServer::get_singleton()->free(_vertex_light);
}
void VertexLight2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
VertexLights2DServer::get_singleton()->light_set_position(_vertex_light, get_global_transform().get_origin());
} break;
}
}
void VertexLight2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_color"), &VertexLight2D::get_color);
ClassDB::bind_method(D_METHOD("set_color", "color"), &VertexLight2D::set_color);

View File

@ -71,6 +71,8 @@ public:
~VertexLight2D();
protected:
void _notification(int p_what);
static void _bind_methods();
RID _vertex_light;