mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-28 03:49:18 +01:00
Fix VertexLights2DServer's changed notification setup.
This commit is contained in:
parent
59a4fcfc70
commit
a593fdff63
@ -56,8 +56,6 @@ void unregister_vertex_lights_2d_types(ModuleRegistrationLevel p_level) {
|
|||||||
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
|
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
|
||||||
if (vertex_lights_2d_server) {
|
if (vertex_lights_2d_server) {
|
||||||
memdelete(vertex_lights_2d_server);
|
memdelete(vertex_lights_2d_server);
|
||||||
} else if (p_level == MODULE_REGISTRATION_LEVEL_FINALIZE) {
|
|
||||||
vertex_lights_2d_server->finalize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@ void VertexLights2DServer::map_set_base_color(RID p_map, const Color &p_base_col
|
|||||||
_map_changed(map);
|
_map_changed(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Array VertexLights2DServer::map_get_lights(RID p_map) const {
|
Array VertexLights2DServer::map_get_lights(RID p_map) const {
|
||||||
VertexLightMap2D *map = map_owner.getornull(p_map);
|
VertexLightMap2D *map = map_owner.getornull(p_map);
|
||||||
ERR_FAIL_COND_V(map == NULL, Array());
|
ERR_FAIL_COND_V(map == NULL, Array());
|
||||||
@ -336,12 +335,23 @@ void VertexLights2DServer::free(RID p_rid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VertexLights2DServer::init() {
|
void VertexLights2DServer::init() {
|
||||||
|
call_deferred("_register_update");
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexLights2DServer::register_update() {
|
||||||
if (SceneTree::get_singleton()) {
|
if (SceneTree::get_singleton()) {
|
||||||
SceneTree::get_singleton()->add_idle_callback(VertexLights2DServer::_scene_tree_idle_callback);
|
if (!SceneTree::get_singleton()->is_connected("idle_frame", this, "flush_notifications")) {
|
||||||
|
SceneTree::get_singleton()->connect("idle_frame", this, "flush_notifications");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexLights2DServer::finalize() {
|
void VertexLights2DServer::unregister_update() {
|
||||||
|
if (SceneTree::get_singleton()) {
|
||||||
|
if (SceneTree::get_singleton()->is_connected("idle_frame", this, "flush_notifications")) {
|
||||||
|
SceneTree::get_singleton()->disconnect("idle_frame", this, "flush_notifications");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexLights2DServer::flush_notifications() {
|
void VertexLights2DServer::flush_notifications() {
|
||||||
@ -427,6 +437,7 @@ void VertexLights2DServer::_bind_methods() {
|
|||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("free", "rid"), &VertexLights2DServer::free);
|
ClassDB::bind_method(D_METHOD("free", "rid"), &VertexLights2DServer::free);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("_register_update"), &VertexLights2DServer::register_update);
|
||||||
ClassDB::bind_method(D_METHOD("flush_notifications"), &VertexLights2DServer::flush_notifications);
|
ClassDB::bind_method(D_METHOD("flush_notifications"), &VertexLights2DServer::flush_notifications);
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_ADD);
|
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_ADD);
|
||||||
|
@ -115,7 +115,6 @@ public:
|
|||||||
void free(RID p_rid);
|
void free(RID p_rid);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void finalize();
|
|
||||||
void flush_notifications();
|
void flush_notifications();
|
||||||
|
|
||||||
_FORCE_INLINE_ static VertexLights2DServer *get_singleton() {
|
_FORCE_INLINE_ static VertexLights2DServer *get_singleton() {
|
||||||
@ -126,9 +125,8 @@ public:
|
|||||||
~VertexLights2DServer();
|
~VertexLights2DServer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _scene_tree_idle_callback() {
|
void register_update();
|
||||||
VertexLights2DServer::get_singleton()->flush_notifications();
|
void unregister_update();
|
||||||
}
|
|
||||||
|
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user