aboutsummaryrefslogtreecommitdiff
path: root/scene/2d/light_2d.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-03-10 21:05:49 -0300
committerJuan Linietsky2015-03-10 21:05:49 -0300
commita6f96f46b779a815b03974fece21728fe32e88d2 (patch)
tree8f450cd516f009e38d9909255bbca283a8868368 /scene/2d/light_2d.cpp
parent57380f9aba2352755273acb9dcd5f20351e668ce (diff)
downloadgodot-a6f96f46b779a815b03974fece21728fe32e88d2.tar.gz
godot-a6f96f46b779a815b03974fece21728fe32e88d2.tar.zst
godot-a6f96f46b779a815b03974fece21728fe32e88d2.zip
small optimizations to isometric light demo
should work faster, and even faster if exported.. as textures have been optimized.
Diffstat (limited to 'scene/2d/light_2d.cpp')
-rw-r--r--scene/2d/light_2d.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index 5472e0b00..8f6907798 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -23,7 +23,7 @@ Rect2 Light2D::get_item_rect() const {
Size2i s;
- s = texture->get_size();
+ s = texture->get_size()*scale;
Point2i ofs=texture_offset;
ofs-=s/2;
@@ -63,6 +63,8 @@ void Light2D::set_texture_offset( const Vector2& p_offset) {
texture_offset=p_offset;
VS::get_singleton()->canvas_light_set_texture_offset(canvas_light,texture_offset);
+ item_rect_changed();
+
}
Vector2 Light2D::get_texture_offset() const {
@@ -87,11 +89,27 @@ void Light2D::set_height( float p_height) {
VS::get_singleton()->canvas_light_set_height(canvas_light,height);
}
+
+
float Light2D::get_height() const {
return height;
}
+void Light2D::set_scale( float p_scale) {
+
+ scale=p_scale;
+ VS::get_singleton()->canvas_light_set_scale(canvas_light,scale);
+ item_rect_changed();
+
+}
+
+
+float Light2D::get_scale() const {
+
+ return scale;
+}
+
void Light2D::set_z_range_min( int p_min_z) {
z_min=p_min_z;
@@ -242,6 +260,10 @@ void Light2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_height","height"),&Light2D::set_height);
ObjectTypeDB::bind_method(_MD("get_height"),&Light2D::get_height);
+ ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Light2D::set_scale);
+ ObjectTypeDB::bind_method(_MD("get_scale"),&Light2D::get_scale);
+
+
ObjectTypeDB::bind_method(_MD("set_z_range_min","z"),&Light2D::set_z_range_min);
ObjectTypeDB::bind_method(_MD("get_z_range_min"),&Light2D::get_z_range_min);
@@ -276,6 +298,7 @@ void Light2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("set_scale"),_SCS("get_scale"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"subtract"),_SCS("set_subtract_mode"),_SCS("get_subtract_mode"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height"),_SCS("set_height"),_SCS("get_height"));
@@ -299,6 +322,7 @@ Light2D::Light2D() {
shadow=false;
color=Color(1,1,1);
height=0;
+ scale=1.0;
z_min=-1024;
z_max=1024;
layer_min=0;