summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/area_2d.cpp6
-rw-r--r--scene/2d/canvas_item.cpp18
-rw-r--r--scene/2d/canvas_modulate.cpp2
-rw-r--r--scene/2d/light_2d.cpp6
-rw-r--r--scene/2d/path_2d.cpp2
-rw-r--r--scene/2d/polygon_2d.cpp27
-rw-r--r--scene/2d/polygon_2d.h4
-rw-r--r--scene/2d/sprite.cpp2
8 files changed, 45 insertions, 22 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 8b7aff3b7a..71728966fd 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -660,9 +660,9 @@ void Area2D::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.001"),_SCS("set_gravity"),_SCS("get_gravity"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 21615b7f55..17e5503a2d 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -455,20 +455,15 @@ void CanvasItem::_enter_canvas() {
if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) {
Node *n = this;
- Viewport *viewport=NULL;
+
canvas_layer=NULL;
while(n) {
- if (n->cast_to<Viewport>()) {
-
- viewport = n->cast_to<Viewport>();
+ canvas_layer = n->cast_to<CanvasLayer>();
+ if (canvas_layer) {
break;
}
- if (!canvas_layer && n->cast_to<CanvasLayer>()) {
-
- canvas_layer = n->cast_to<CanvasLayer>();
- }
n=n->get_parent();
}
@@ -476,7 +471,7 @@ void CanvasItem::_enter_canvas() {
if (canvas_layer)
canvas=canvas_layer->get_world_2d()->get_canvas();
else
- canvas=viewport->find_world_2d()->get_canvas();
+ canvas=get_viewport()->find_world_2d()->get_canvas();
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,canvas);
@@ -488,6 +483,7 @@ void CanvasItem::_enter_canvas() {
} else {
CanvasItem *parent = get_parent_item();
+ canvas_layer=parent->canvas_layer;
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
parent->_queue_sort_children();
}
@@ -1176,12 +1172,10 @@ Matrix32 CanvasItem::get_viewport_transform() const {
return canvas_layer->get_transform();
}
- } else if (get_viewport()) {
+ } else {
return get_viewport()->get_final_transform() * get_viewport()->get_canvas_transform();
}
- return Matrix32();
-
}
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index cc0db2da77..6a74cb1d91 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -62,7 +62,7 @@ String CanvasModulate::get_configuration_warning() const {
get_tree()->get_nodes_in_group("_canvas_modulate_"+itos(get_canvas().get_id()),&nodes);
if (nodes.size()>1) {
- return TTR("Only one visible CanvasModulate is allowed per scene (or set of instanced scenes). The first one created will work, while the rest will be ignored.");
+ return TTR("Only one visible CanvasModulate is allowed per scene (or set of instanced scenes). The first created one will work, while the rest will be ignored.");
}
return String();
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index b79c07360b..1cb34075bb 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -357,11 +357,11 @@ 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_texture_scale"),_SCS("get_texture_scale"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy"),_SCS("set_energy"),_SCS("get_energy"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0.01,100,0.01"),_SCS("set_energy"),_SCS("get_energy"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height"),_SCS("set_height"),_SCS("get_height"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index dee67a829f..41ca7b1d0f 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -243,7 +243,7 @@ String PathFollow2D::get_configuration_warning() const {
return String();
if (!get_parent() || !get_parent()->cast_to<Path2D>()) {
- return TTR("PathFolow2D only works when set as a child of a Path2D node.");
+ return TTR("PathFollow2D only works when set as a child of a Path2D node.");
}
return String();
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index fc6986327f..03ced12c55 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -145,7 +145,18 @@ void Polygon2D::_notification(int p_what) {
Vector<Color> colors;
- colors.push_back(color);
+ int color_len=vertex_colors.size();
+ colors.resize(len);
+ {
+ DVector<Color>::Read color_r=vertex_colors.read();
+ for(int i=0;i<color_len && i<len;i++){
+ colors[i]=color_r[i];
+ }
+ for(int i=color_len;i<len;i++){
+ colors[i]=color;
+ }
+ }
+
Vector<int> indices = Geometry::triangulate_polygon(points);
VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(),indices,points,colors,uvs,texture.is_valid()?texture->get_rid():RID());
@@ -188,6 +199,16 @@ Color Polygon2D::get_color() const{
return color;
}
+void Polygon2D::set_vertex_colors(const DVector<Color>& p_colors){
+
+ vertex_colors=p_colors;
+ update();
+}
+DVector<Color> Polygon2D::get_vertex_colors() const{
+
+ return vertex_colors;
+}
+
void Polygon2D::set_texture(const Ref<Texture>& p_texture){
texture=p_texture;
@@ -293,6 +314,9 @@ void Polygon2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_color","color"),&Polygon2D::set_color);
ObjectTypeDB::bind_method(_MD("get_color"),&Polygon2D::get_color);
+ ObjectTypeDB::bind_method(_MD("set_vertex_colors","vertex_colors"),&Polygon2D::set_vertex_colors);
+ ObjectTypeDB::bind_method(_MD("get_vertex_colors"),&Polygon2D::get_vertex_colors);
+
ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Polygon2D::set_texture);
ObjectTypeDB::bind_method(_MD("get_texture"),&Polygon2D::get_texture);
@@ -323,6 +347,7 @@ void Polygon2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture/offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index 517b623ccd..eaa642787c 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -9,6 +9,7 @@ class Polygon2D : public Node2D {
DVector<Vector2> polygon;
DVector<Vector2> uv;
+ DVector<Color> vertex_colors;
Color color;
Ref<Texture> texture;
Vector2 tex_scale;
@@ -40,6 +41,9 @@ public:
void set_color(const Color& p_color);
Color get_color() const;
+ void set_vertex_colors(const DVector<Color>& p_colors);
+ DVector<Color> get_vertex_colors() const;
+
void set_texture(const Ref<Texture>& p_texture);
Ref<Texture> get_texture() const;
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index aebb9a4c28..3e6384ea2c 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -540,7 +540,7 @@ String ViewportSprite::get_configuration_warning() const {
Viewport *vp = n->cast_to<Viewport>();
if (!vp->is_set_as_render_target()) {
- return TTR("The Viewport set in the path property must be set as 'render taget' in order for this sprite to work");
+ return TTR("The Viewport set in the path property must be set as 'render target' in order for this sprite to work.");
}
}
}