mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-08 04:51:49 +02:00
Added enabled property for VertexLight2Ds.
This commit is contained in:
parent
9df448113d
commit
02fe45b08a
@ -31,6 +31,17 @@
|
|||||||
|
|
||||||
#include "vertex_light_2d.h"
|
#include "vertex_light_2d.h"
|
||||||
|
|
||||||
|
#include "core/config/engine.h"
|
||||||
|
|
||||||
|
bool VertexLight2D::get_is_enabled() {
|
||||||
|
return _enabled;
|
||||||
|
}
|
||||||
|
void VertexLight2D::set_enabled(const bool p_enabled) {
|
||||||
|
_enabled = p_enabled;
|
||||||
|
|
||||||
|
_update_light_visibility();
|
||||||
|
}
|
||||||
|
|
||||||
Color VertexLight2D::get_color() {
|
Color VertexLight2D::get_color() {
|
||||||
return _color;
|
return _color;
|
||||||
}
|
}
|
||||||
@ -79,6 +90,7 @@ void VertexLight2D::set_item_cull_mask(const int p_item_cull_mask) {
|
|||||||
VertexLight2D::VertexLight2D() {
|
VertexLight2D::VertexLight2D() {
|
||||||
_vertex_light = RID_PRIME(VertexLights2DServer::get_singleton()->light_create());
|
_vertex_light = RID_PRIME(VertexLights2DServer::get_singleton()->light_create());
|
||||||
|
|
||||||
|
_enabled = true;
|
||||||
_color = Color(1, 1, 1, 1);
|
_color = Color(1, 1, 1, 1);
|
||||||
_item_cull_mask = 1;
|
_item_cull_mask = 1;
|
||||||
_z_range = Vector2i(-1024, 1024);
|
_z_range = Vector2i(-1024, 1024);
|
||||||
@ -96,10 +108,25 @@ void VertexLight2D::_notification(int p_what) {
|
|||||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||||
VertexLights2DServer::get_singleton()->light_set_position(_vertex_light, get_global_transform().get_origin());
|
VertexLights2DServer::get_singleton()->light_set_position(_vertex_light, get_global_transform().get_origin());
|
||||||
} break;
|
} break;
|
||||||
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||||
|
_update_light_visibility();
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VertexLight2D::_update_light_visibility() {
|
||||||
|
if (!is_inside_tree()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexLights2DServer::get_singleton()->light_set_enabled(_vertex_light, _enabled && is_visible_in_tree());
|
||||||
|
}
|
||||||
|
|
||||||
void VertexLight2D::_bind_methods() {
|
void VertexLight2D::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_is_enabled"), &VertexLight2D::get_is_enabled);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &VertexLight2D::set_enabled);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "get_is_enabled");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_color"), &VertexLight2D::get_color);
|
ClassDB::bind_method(D_METHOD("get_color"), &VertexLight2D::get_color);
|
||||||
ClassDB::bind_method(D_METHOD("set_color", "color"), &VertexLight2D::set_color);
|
ClassDB::bind_method(D_METHOD("set_color", "color"), &VertexLight2D::set_color);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
|
||||||
|
@ -52,6 +52,9 @@ public:
|
|||||||
//VERTEX_LIGHT_2D_MODE_MASK = VertexLights2DServer::VERTEX_LIGHT_2D_MODE_MASK
|
//VERTEX_LIGHT_2D_MODE_MASK = VertexLights2DServer::VERTEX_LIGHT_2D_MODE_MASK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool get_is_enabled();
|
||||||
|
void set_enabled(const bool p_enabled);
|
||||||
|
|
||||||
Color get_color();
|
Color get_color();
|
||||||
void set_color(const Color &p_color);
|
void set_color(const Color &p_color);
|
||||||
|
|
||||||
@ -73,10 +76,13 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
|
void _update_light_visibility();
|
||||||
|
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
RID _vertex_light;
|
RID _vertex_light;
|
||||||
|
|
||||||
|
bool _enabled;
|
||||||
Color _color;
|
Color _color;
|
||||||
VertexLight2DMode _mode;
|
VertexLight2DMode _mode;
|
||||||
Vector2i _z_range;
|
Vector2i _z_range;
|
||||||
|
@ -47,6 +47,7 @@ class VertexLightData2D;
|
|||||||
|
|
||||||
class VertexLightData2D : public RID_Data {
|
class VertexLightData2D : public RID_Data {
|
||||||
public:
|
public:
|
||||||
|
bool enabled;
|
||||||
Vector2 position;
|
Vector2 position;
|
||||||
Color color;
|
Color color;
|
||||||
VertexLights2DServer::VertexLight2DMode mode;
|
VertexLights2DServer::VertexLight2DMode mode;
|
||||||
@ -63,6 +64,7 @@ public:
|
|||||||
map = NULL;
|
map = NULL;
|
||||||
quadrant = NULL;
|
quadrant = NULL;
|
||||||
|
|
||||||
|
enabled = true;
|
||||||
color = Color(1, 1, 1, 1);
|
color = Color(1, 1, 1, 1);
|
||||||
item_cull_mask = 1;
|
item_cull_mask = 1;
|
||||||
z_range = Vector2i(-1024, 1024);
|
z_range = Vector2i(-1024, 1024);
|
||||||
|
@ -124,6 +124,19 @@ void VertexLights2DServer::light_set_map(RID p_light, RID p_map) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VertexLights2DServer::light_get_is_enabled(RID p_light) {
|
||||||
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
||||||
|
ERR_FAIL_COND_V(light == NULL, false);
|
||||||
|
|
||||||
|
return light->enabled;
|
||||||
|
}
|
||||||
|
void VertexLights2DServer::light_set_enabled(RID p_light, const bool p_enabled) {
|
||||||
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
||||||
|
ERR_FAIL_COND(light == NULL);
|
||||||
|
|
||||||
|
light->enabled = p_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 VertexLights2DServer::light_get_position(RID p_light) {
|
Vector2 VertexLights2DServer::light_get_position(RID p_light) {
|
||||||
const VertexLightData2D *light = light_owner.getornull(p_light);
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
||||||
ERR_FAIL_COND_V(light == NULL, Vector2());
|
ERR_FAIL_COND_V(light == NULL, Vector2());
|
||||||
@ -274,6 +287,9 @@ void VertexLights2DServer::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("light_get_map", "light"), &VertexLights2DServer::light_get_map);
|
ClassDB::bind_method(D_METHOD("light_get_map", "light"), &VertexLights2DServer::light_get_map);
|
||||||
ClassDB::bind_method(D_METHOD("light_set_map", "light", "map"), &VertexLights2DServer::light_set_map);
|
ClassDB::bind_method(D_METHOD("light_set_map", "light", "map"), &VertexLights2DServer::light_set_map);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("light_get_is_enabled", "light"), &VertexLights2DServer::light_get_is_enabled);
|
||||||
|
ClassDB::bind_method(D_METHOD("light_set_enabled", "light", "enabled"), &VertexLights2DServer::light_set_enabled);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("light_get_position", "light"), &VertexLights2DServer::light_get_position);
|
ClassDB::bind_method(D_METHOD("light_get_position", "light"), &VertexLights2DServer::light_get_position);
|
||||||
ClassDB::bind_method(D_METHOD("light_set_position", "light", "position"), &VertexLights2DServer::light_set_position);
|
ClassDB::bind_method(D_METHOD("light_set_position", "light", "position"), &VertexLights2DServer::light_set_position);
|
||||||
|
|
||||||
|
@ -77,6 +77,9 @@ public:
|
|||||||
RID light_get_map(RID p_light);
|
RID light_get_map(RID p_light);
|
||||||
void light_set_map(RID p_light, RID p_map);
|
void light_set_map(RID p_light, RID p_map);
|
||||||
|
|
||||||
|
bool light_get_is_enabled(RID p_light);
|
||||||
|
void light_set_enabled(RID p_light, const bool p_enabled);
|
||||||
|
|
||||||
Vector2 light_get_position(RID p_light);
|
Vector2 light_get_position(RID p_light);
|
||||||
void light_set_position(RID p_light, const Vector2 &p_position);
|
void light_set_position(RID p_light, const Vector2 &p_position);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user