summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorCarl Olsson <carl.olsson@gmail.com>2015-03-23 08:19:20 +1000
committerCarl Olsson <carl.olsson@gmail.com>2015-03-23 08:19:20 +1000
commitfb2cdfe7edcc2ccafea7604afd104f582e5b9c17 (patch)
treed9555d9519648f95d7ed3663fbca50978bb12a1f /scene
parent41686d5fdd0d72f167894f976d19b177789f1f63 (diff)
parente9f94ce8d2cc6805e74fffdf733e6dc5b5c530f5 (diff)
Merge branch 'master' of https://github.com/not-surt/godot into snapping2
Conflicts: tools/editor/plugins/canvas_item_editor_plugin.cpp tools/editor/plugins/canvas_item_editor_plugin.h
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/area_2d.cpp261
-rw-r--r--scene/2d/area_2d.h37
-rw-r--r--scene/2d/back_buffer_copy.cpp75
-rw-r--r--scene/2d/back_buffer_copy.h41
-rw-r--r--scene/2d/camera_2d.cpp11
-rw-r--r--scene/2d/camera_2d.h189
-rw-r--r--scene/2d/canvas_item.cpp343
-rw-r--r--scene/2d/canvas_item.h60
-rw-r--r--scene/2d/collision_object_2d.cpp71
-rw-r--r--scene/2d/collision_object_2d.h12
-rw-r--r--scene/2d/light_2d.cpp92
-rw-r--r--scene/2d/light_2d.h16
-rw-r--r--scene/2d/light_occluder_2d.cpp202
-rw-r--r--scene/2d/light_occluder_2d.h73
-rw-r--r--scene/2d/node_2d.cpp49
-rw-r--r--scene/2d/node_2d.h8
-rw-r--r--scene/2d/particles_2d.cpp5
-rw-r--r--scene/2d/physics_body_2d.cpp1
-rw-r--r--scene/2d/tile_map.cpp309
-rw-r--r--scene/2d/tile_map.h41
-rw-r--r--scene/2d/visibility_notifier_2d.cpp22
-rw-r--r--scene/2d/visibility_notifier_2d.h1
-rw-r--r--scene/3d/camera.cpp24
-rw-r--r--scene/3d/camera.h2
-rw-r--r--scene/3d/spatial.cpp113
-rw-r--r--scene/3d/spatial.h15
-rw-r--r--scene/3d/visual_instance.cpp15
-rw-r--r--scene/3d/visual_instance.h4
-rw-r--r--scene/gui/base_button.cpp5
-rw-r--r--scene/gui/check_box.cpp79
-rw-r--r--scene/gui/check_box.h55
-rw-r--r--scene/gui/color_picker.cpp1
-rw-r--r--scene/gui/control.cpp84
-rw-r--r--scene/gui/file_dialog.cpp19
-rw-r--r--scene/gui/label.cpp4
-rw-r--r--scene/gui/text_edit.cpp53
-rw-r--r--scene/main/viewport.cpp71
-rw-r--r--scene/main/viewport.h1
-rw-r--r--scene/register_scene_types.cpp10
-rw-r--r--scene/resources/default_theme/default_theme.cpp38
-rw-r--r--scene/resources/default_theme/radio_checked.pngbin0 -> 569 bytes
-rw-r--r--scene/resources/default_theme/radio_unchecked.pngbin0 -> 421 bytes
-rw-r--r--scene/resources/default_theme/theme_data.h10
-rw-r--r--scene/resources/environment.cpp7
-rw-r--r--scene/resources/environment.h6
-rw-r--r--scene/resources/font.cpp21
-rw-r--r--scene/resources/font.h4
-rw-r--r--scene/resources/texture.cpp9
-rw-r--r--scene/resources/texture.h2
-rw-r--r--scene/resources/tile_set.cpp106
-rw-r--r--scene/resources/tile_set.h22
-rw-r--r--scene/resources/world.cpp6
-rw-r--r--scene/resources/world.h2
-rw-r--r--scene/resources/world_2d.cpp9
-rw-r--r--scene/resources/world_2d.h4
-rw-r--r--scene/scene_string_names.cpp7
-rw-r--r--scene/scene_string_names.h8
57 files changed, 2357 insertions, 378 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index fce21f6001..a5c455ce64 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -216,6 +216,119 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
}
+
+void Area2D::_area_enter_tree(ObjectID p_id) {
+
+ Object *obj = ObjectDB::get_instance(p_id);
+ Node *node = obj ? obj->cast_to<Node>() : NULL;
+ ERR_FAIL_COND(!node);
+
+ Map<ObjectID,AreaState>::Element *E=area_map.find(p_id);
+ ERR_FAIL_COND(!E);
+ ERR_FAIL_COND(E->get().in_tree);
+
+ E->get().in_tree=true;
+ emit_signal(SceneStringNames::get_singleton()->area_enter,node);
+ for(int i=0;i<E->get().shapes.size();i++) {
+
+ emit_signal(SceneStringNames::get_singleton()->area_enter_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ }
+
+}
+
+void Area2D::_area_exit_tree(ObjectID p_id) {
+
+ Object *obj = ObjectDB::get_instance(p_id);
+ Node *node = obj ? obj->cast_to<Node>() : NULL;
+ ERR_FAIL_COND(!node);
+ Map<ObjectID,AreaState>::Element *E=area_map.find(p_id);
+ ERR_FAIL_COND(!E);
+ ERR_FAIL_COND(!E->get().in_tree);
+ E->get().in_tree=false;
+ emit_signal(SceneStringNames::get_singleton()->area_exit,node);
+ for(int i=0;i<E->get().shapes.size();i++) {
+
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ }
+
+}
+
+void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_area_shape,int p_self_shape) {
+
+ bool area_in = p_status==Physics2DServer::AREA_BODY_ADDED;
+ ObjectID objid=p_instance;
+
+ Object *obj = ObjectDB::get_instance(objid);
+ Node *node = obj ? obj->cast_to<Node>() : NULL;
+
+ Map<ObjectID,AreaState>::Element *E=area_map.find(objid);
+
+ ERR_FAIL_COND(!area_in && !E);
+
+ locked=true;
+
+ if (area_in) {
+ if (!E) {
+
+ E = area_map.insert(objid,AreaState());
+ E->get().rc=0;
+ E->get().in_tree=node && node->is_inside_tree();
+ if (node) {
+ node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid));
+ if (E->get().in_tree) {
+ emit_signal(SceneStringNames::get_singleton()->area_enter,node);
+ }
+ }
+
+ }
+ E->get().rc++;
+ if (node)
+ E->get().shapes.insert(AreaShapePair(p_area_shape,p_self_shape));
+
+
+ if (!node || E->get().in_tree) {
+ emit_signal(SceneStringNames::get_singleton()->area_enter_shape,objid,node,p_area_shape,p_self_shape);
+ }
+
+ } else {
+
+ E->get().rc--;
+
+ if (node)
+ E->get().shapes.erase(AreaShapePair(p_area_shape,p_self_shape));
+
+ bool eraseit=false;
+
+ if (E->get().rc==0) {
+
+ if (node) {
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ if (E->get().in_tree)
+ emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+
+ }
+
+ eraseit=true;
+
+ }
+ if (!node || E->get().in_tree) {
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape,objid,obj,p_area_shape,p_self_shape);
+ }
+
+ if (eraseit)
+ area_map.erase(E);
+
+ }
+
+ locked=false;
+
+
+}
+
+
+
void Area2D::_clear_monitoring() {
if (locked) {
@@ -223,27 +336,56 @@ void Area2D::_clear_monitoring() {
}
ERR_FAIL_COND(locked);
- Map<ObjectID,BodyState> bmcopy = body_map;
- body_map.clear();
- //disconnect all monitored stuff
+ {
+ Map<ObjectID,BodyState> bmcopy = body_map;
+ body_map.clear();
+ //disconnect all monitored stuff
- for (Map<ObjectID,BodyState>::Element *E=bmcopy.front();E;E=E->next()) {
+ for (Map<ObjectID,BodyState>::Element *E=bmcopy.front();E;E=E->next()) {
- Object *obj = ObjectDB::get_instance(E->key());
- Node *node = obj ? obj->cast_to<Node>() : NULL;
- ERR_CONTINUE(!node);
- if (!E->get().in_tree)
- continue;
+ Object *obj = ObjectDB::get_instance(E->key());
+ Node *node = obj ? obj->cast_to<Node>() : NULL;
+ ERR_CONTINUE(!node);
+ if (!E->get().in_tree)
+ continue;
- for(int i=0;i<E->get().shapes.size();i++) {
+ for(int i=0;i<E->get().shapes.size();i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ }
+
+ emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
}
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ }
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ {
+
+ Map<ObjectID,AreaState> bmcopy = area_map;
+ area_map.clear();
+ //disconnect all monitored stuff
+
+ for (Map<ObjectID,AreaState>::Element *E=bmcopy.front();E;E=E->next()) {
+
+ Object *obj = ObjectDB::get_instance(E->key());
+ Node *node = obj ? obj->cast_to<Node>() : NULL;
+ ERR_CONTINUE(!node);
+ if (!E->get().in_tree)
+ continue;
+
+ for(int i=0;i<E->get().shapes.size();i++) {
+
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ }
+
+ emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ }
}
}
@@ -276,8 +418,10 @@ void Area2D::set_enable_monitoring(bool p_enable) {
if (monitoring) {
Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(),this,"_body_inout");
+ Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(),this,"_area_inout");
} else {
Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(),NULL,StringName());
+ Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(),NULL,StringName());
_clear_monitoring();
}
@@ -288,6 +432,26 @@ bool Area2D::is_monitoring_enabled() const {
return monitoring;
}
+void Area2D::set_monitorable(bool p_enable) {
+
+ if (locked) {
+ ERR_EXPLAIN("This function can't be used during the in/out signal.");
+ }
+ ERR_FAIL_COND(locked);
+
+ if (p_enable==monitorable)
+ return;
+
+ monitorable=p_enable;
+
+ Physics2DServer::get_singleton()->area_set_monitorable(get_rid(),monitorable);
+}
+
+bool Area2D::is_monitorable() const {
+
+ return monitorable;
+}
+
Array Area2D::get_overlapping_bodies() const {
ERR_FAIL_COND_V(!monitoring,Array());
@@ -307,12 +471,56 @@ Array Area2D::get_overlapping_bodies() const {
return ret;
}
+Array Area2D::get_overlapping_areas() const {
+
+ ERR_FAIL_COND_V(!monitoring,Array());
+ Array ret;
+ ret.resize(area_map.size());
+ int idx=0;
+ for (const Map<ObjectID,AreaState>::Element *E=area_map.front();E;E=E->next()) {
+ Object *obj = ObjectDB::get_instance(E->key());
+ if (!obj) {
+ ret.resize( ret.size() -1 ); //ops
+ } else {
+ ret[idx++]=obj;
+ }
+
+ }
+
+ return ret;
+}
+
+bool Area2D::overlaps_area(Node* p_area) const {
+
+ ERR_FAIL_NULL_V(p_area,false);
+ const Map<ObjectID,AreaState>::Element *E=area_map.find(p_area->get_instance_ID());
+ if (!E)
+ return false;
+ return E->get().in_tree;
+
+
+
+}
+
+bool Area2D::overlaps_body(Node* p_body) const{
+
+ ERR_FAIL_NULL_V(p_body,false);
+ const Map<ObjectID,BodyState>::Element *E=body_map.find(p_body->get_instance_ID());
+ if (!E)
+ return false;
+ return E->get().in_tree;
+
+}
+
void Area2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_body_enter_tree","id"),&Area2D::_body_enter_tree);
ObjectTypeDB::bind_method(_MD("_body_exit_tree","id"),&Area2D::_body_exit_tree);
+ ObjectTypeDB::bind_method(_MD("_area_enter_tree","id"),&Area2D::_area_enter_tree);
+ ObjectTypeDB::bind_method(_MD("_area_exit_tree","id"),&Area2D::_area_exit_tree);
+
ObjectTypeDB::bind_method(_MD("set_space_override_mode","enable"),&Area2D::set_space_override_mode);
ObjectTypeDB::bind_method(_MD("get_space_override_mode"),&Area2D::get_space_override_mode);
@@ -337,15 +545,29 @@ void Area2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring);
ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled);
+ ObjectTypeDB::bind_method(_MD("set_monitorable","enable"),&Area2D::set_monitorable);
+ ObjectTypeDB::bind_method(_MD("is_monitorable"),&Area2D::is_monitorable);
+
ObjectTypeDB::bind_method(_MD("get_overlapping_bodies"),&Area2D::get_overlapping_bodies);
+ ObjectTypeDB::bind_method(_MD("get_overlapping_areas"),&Area2D::get_overlapping_areas);
+
+ ObjectTypeDB::bind_method(_MD("overlaps_body:PhysicsBody2D","body"),&Area2D::overlaps_body);
+ ObjectTypeDB::bind_method(_MD("overlaps_area:Area2D","area"),&Area2D::overlaps_area);
ObjectTypeDB::bind_method(_MD("_body_inout"),&Area2D::_body_inout);
+ ObjectTypeDB::bind_method(_MD("_area_inout"),&Area2D::_area_inout);
+
+
+ ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
+ ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
+ ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape")));
+ ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
+ ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Replace"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
@@ -355,6 +577,7 @@ void Area2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_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_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
}
@@ -369,7 +592,9 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea
locked=false;
priority=0;
monitoring=false;
+ monitorable=false;
set_enable_monitoring(true);
+ set_monitorable(true);
}
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index f770e88a19..6a6c757e0c 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -53,6 +53,7 @@ private:
real_t angular_damp;
int priority;
bool monitoring;
+ bool monitorable;
bool locked;
void _body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape);
@@ -84,6 +85,36 @@ private:
Map<ObjectID,BodyState> body_map;
+
+
+ void _area_inout(int p_status,const RID& p_area, int p_instance, int p_area_shape,int p_self_shape);
+
+ void _area_enter_tree(ObjectID p_id);
+ void _area_exit_tree(ObjectID p_id);
+
+ struct AreaShapePair {
+
+ int area_shape;
+ int self_shape;
+ bool operator<(const AreaShapePair& p_sp) const {
+ if (area_shape==p_sp.area_shape)
+ return self_shape < p_sp.self_shape;
+ else
+ return area_shape < p_sp.area_shape;
+ }
+
+ AreaShapePair() {}
+ AreaShapePair(int p_bs, int p_as) { area_shape=p_bs; self_shape=p_as; }
+ };
+
+ struct AreaState {
+
+ int rc;
+ bool in_tree;
+ VSet<AreaShapePair> shapes;
+ };
+
+ Map<ObjectID,AreaState> area_map;
void _clear_monitoring();
@@ -117,8 +148,14 @@ public:
void set_enable_monitoring(bool p_enable);
bool is_monitoring_enabled() const;
+ void set_monitorable(bool p_enable);
+ bool is_monitorable() const;
+
Array get_overlapping_bodies() const; //function for script
+ Array get_overlapping_areas() const; //function for script
+ bool overlaps_area(Node* p_area) const;
+ bool overlaps_body(Node* p_body) const;
Area2D();
~Area2D();
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
new file mode 100644
index 0000000000..245b3ba7eb
--- /dev/null
+++ b/scene/2d/back_buffer_copy.cpp
@@ -0,0 +1,75 @@
+#include "back_buffer_copy.h"
+
+void BackBufferCopy::_update_copy_mode() {
+
+ switch(copy_mode) {
+
+ case COPY_MODE_DISALED: {
+
+ VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(),false,Rect2());
+ } break;
+ case COPY_MODE_RECT: {
+
+ VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(),true,rect);
+ } break;
+ case COPY_MODE_VIEWPORT: {
+
+ VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(),true,Rect2());
+
+ } break;
+
+ }
+}
+
+Rect2 BackBufferCopy::get_item_rect() const {
+
+ return rect;
+}
+
+void BackBufferCopy::set_rect(const Rect2& p_rect) {
+
+ rect=p_rect;
+ _update_copy_mode();
+}
+
+Rect2 BackBufferCopy::get_rect() const{
+ return rect;
+}
+
+void BackBufferCopy::set_copy_mode(CopyMode p_mode){
+
+ copy_mode=p_mode;
+ _update_copy_mode();
+}
+BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const{
+
+ return copy_mode;
+}
+
+
+void BackBufferCopy::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_rect","rect"),&BackBufferCopy::set_rect);
+ ObjectTypeDB::bind_method(_MD("get_rect"),&BackBufferCopy::get_rect);
+
+ ObjectTypeDB::bind_method(_MD("set_copy_mode","copy_mode"),&BackBufferCopy::set_copy_mode);
+ ObjectTypeDB::bind_method(_MD("get_copy_mode"),&BackBufferCopy::get_copy_mode);
+
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"copy_mode",PROPERTY_HINT_ENUM,"Disabled,Rect,Viewport"),_SCS("set_copy_mode"),_SCS("get_copy_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect"));
+
+ BIND_CONSTANT( COPY_MODE_DISALED );
+ BIND_CONSTANT( COPY_MODE_RECT );
+ BIND_CONSTANT( COPY_MODE_VIEWPORT );
+
+}
+
+BackBufferCopy::BackBufferCopy(){
+
+ rect=Rect2(-100,-100,200,200);
+ copy_mode=COPY_MODE_RECT;
+ _update_copy_mode();
+}
+BackBufferCopy::~BackBufferCopy(){
+
+}
diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h
new file mode 100644
index 0000000000..3a86ffa309
--- /dev/null
+++ b/scene/2d/back_buffer_copy.h
@@ -0,0 +1,41 @@
+#ifndef BACKBUFFERCOPY_H
+#define BACKBUFFERCOPY_H
+
+#include "scene/2d/node_2d.h"
+
+class BackBufferCopy : public Node2D {
+ OBJ_TYPE( BackBufferCopy,Node2D);
+public:
+ enum CopyMode {
+ COPY_MODE_DISALED,
+ COPY_MODE_RECT,
+ COPY_MODE_VIEWPORT
+ };
+private:
+
+ Rect2 rect;
+ CopyMode copy_mode;
+
+ void _update_copy_mode();
+
+protected:
+
+ static void _bind_methods();
+
+public:
+
+ void set_rect(const Rect2& p_rect);
+ Rect2 get_rect() const;
+
+ void set_copy_mode(CopyMode p_mode);
+ CopyMode get_copy_mode() const;
+
+ Rect2 get_item_rect() const;
+
+ BackBufferCopy();
+ ~BackBufferCopy();
+};
+
+VARIANT_ENUM_CAST(BackBufferCopy::CopyMode);
+
+#endif // BACKBUFFERCOPY_H
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index b3897010bf..b2d74b4ad5 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -323,6 +323,16 @@ void Camera2D::make_current() {
}
}
+void Camera2D::clear_current() {
+
+ current=false;
+ if (is_inside_tree()) {
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL));
+ }
+
+}
+
+
void Camera2D::set_limit(Margin p_margin,int p_limit) {
ERR_FAIL_INDEX(p_margin,4);
@@ -435,6 +445,7 @@ void Camera2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_rotating"),&Camera2D::is_rotating);
ObjectTypeDB::bind_method(_MD("make_current"),&Camera2D::make_current);
+ ObjectTypeDB::bind_method(_MD("clear_current"),&Camera2D::clear_current);
ObjectTypeDB::bind_method(_MD("_make_current"),&Camera2D::_make_current);
ObjectTypeDB::bind_method(_MD("_update_scroll"),&Camera2D::_update_scroll);
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 116169cac1..515f9711bf 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -26,97 +26,98 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef CAMERA_2D_H
-#define CAMERA_2D_H
-
-#include "scene/2d/node_2d.h"
-#include "scene/main/viewport.h"
-
-
-class Camera2D : public Node2D {
-
- OBJ_TYPE( Camera2D, Node2D );
-
-protected:
- Point2 camera_pos;
- Point2 smoothed_camera_pos;
- bool first;
-
- Viewport *viewport;
-
- StringName group_name;
- StringName canvas_group_name;
- RID canvas;
- Vector2 offset;
- Vector2 zoom;
- bool centered;
- bool rotating;
- bool current;
- float smoothing;
- int limit[4];
- float drag_margin[4];
-
- bool h_drag_enabled;
- bool v_drag_enabled;
- float h_ofs;
- float v_ofs;
-
-
- Point2 camera_screen_center;
- void _update_scroll();
-
- void _make_current(Object *p_which);
- void _set_current(bool p_current);
-protected:
-
- virtual Matrix32 get_camera_transform();
- void _notification(int p_what);
- static void _bind_methods();
-public:
-
- void set_offset(const Vector2& p_offset);
- Vector2 get_offset() const;
-
- void set_centered(bool p_centered);
- bool is_centered() const;
-
- void set_rotating(bool p_rotating);
- bool is_rotating() const;
-
- void set_limit(Margin p_margin,int p_limit);
- int get_limit(Margin p_margin) const;
-
-
- void set_h_drag_enabled(bool p_enabled);
- bool is_h_drag_enabled() const;
-
- void set_v_drag_enabled(bool p_enabled);
- bool is_v_drag_enabled() const;
-
- void set_drag_margin(Margin p_margin,float p_drag_margin);
- float get_drag_margin(Margin p_margin) const;
-
- void set_v_offset(float p_offset);
- float get_v_offset() const;
-
- void set_h_offset(float p_offset);
- float get_h_offset() const;
-
- void set_follow_smoothing(float p_speed);
- float get_follow_smoothing() const;
-
- void make_current();
- bool is_current() const;
-
- void set_zoom(const Vector2& p_zoom);
- Vector2 get_zoom() const;
-
- Point2 get_camera_screen_center() const;
-
- Vector2 get_camera_pos() const;
- void force_update_scroll();
-
- Camera2D();
-};
-
-#endif // CAMERA_2D_H
+#ifndef CAMERA_2D_H
+#define CAMERA_2D_H
+
+#include "scene/2d/node_2d.h"
+#include "scene/main/viewport.h"
+
+
+class Camera2D : public Node2D {
+
+ OBJ_TYPE( Camera2D, Node2D );
+
+protected:
+ Point2 camera_pos;
+ Point2 smoothed_camera_pos;
+ bool first;
+
+ Viewport *viewport;
+
+ StringName group_name;
+ StringName canvas_group_name;
+ RID canvas;
+ Vector2 offset;
+ Vector2 zoom;
+ bool centered;
+ bool rotating;
+ bool current;
+ float smoothing;
+ int limit[4];
+ float drag_margin[4];
+
+ bool h_drag_enabled;
+ bool v_drag_enabled;
+ float h_ofs;
+ float v_ofs;
+
+
+ Point2 camera_screen_center;
+ void _update_scroll();
+
+ void _make_current(Object *p_which);
+ void _set_current(bool p_current);
+protected:
+
+ virtual Matrix32 get_camera_transform();
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void set_offset(const Vector2& p_offset);
+ Vector2 get_offset() const;
+
+ void set_centered(bool p_centered);
+ bool is_centered() const;
+
+ void set_rotating(bool p_rotating);
+ bool is_rotating() const;
+
+ void set_limit(Margin p_margin,int p_limit);
+ int get_limit(Margin p_margin) const;
+
+
+ void set_h_drag_enabled(bool p_enabled);
+ bool is_h_drag_enabled() const;
+
+ void set_v_drag_enabled(bool p_enabled);
+ bool is_v_drag_enabled() const;
+
+ void set_drag_margin(Margin p_margin,float p_drag_margin);
+ float get_drag_margin(Margin p_margin) const;
+
+ void set_v_offset(float p_offset);
+ float get_v_offset() const;
+
+ void set_h_offset(float p_offset);
+ float get_h_offset() const;
+
+ void set_follow_smoothing(float p_speed);
+ float get_follow_smoothing() const;
+
+ void make_current();
+ void clear_current();
+ bool is_current() const;
+
+ void set_zoom(const Vector2& p_zoom);
+ Vector2 get_zoom() const;
+
+ Point2 get_camera_screen_center() const;
+
+ Vector2 get_camera_pos() const;
+ void force_update_scroll();
+
+ Camera2D();
+};
+
+#endif // CAMERA_2D_H
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 223adaf9bb..c3ff03d8f4 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -36,6 +36,191 @@
#include "scene/resources/texture.h"
#include "scene/resources/style_box.h"
+
+bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value) {
+
+ if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+ set_shader(p_value);
+ return true;
+ } else if (p_name==SceneStringNames::get_singleton()->shader_unshaded) {
+ set_unshaded(p_value);
+ return true;
+ } else {
+
+ if (shader.is_valid()) {
+
+
+ StringName pr = shader->remap_param(p_name);
+ if (!pr) {
+ String n = p_name;
+ if (n.find("param/")==0) { //backwards compatibility
+ pr = n.substr(6,n.length());
+ }
+ }
+ if (pr) {
+ VisualServer::get_singleton()->canvas_item_material_set_shader_param(material,pr,p_value);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const {
+
+
+ if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+
+ r_ret=get_shader();
+ return true;
+ } else if (p_name==SceneStringNames::get_singleton()->shader_unshaded) {
+
+
+ r_ret=unshaded;
+ return true;
+ } else {
+
+ if (shader.is_valid()) {
+
+ StringName pr = shader->remap_param(p_name);
+ if (pr) {
+ r_ret=VisualServer::get_singleton()->canvas_item_material_get_shader_param(material,pr);
+ return true;
+ }
+ }
+
+ }
+
+
+ return false;
+}
+
+
+void CanvasItemMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
+
+ p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemShader,CanvasItemShaderGraph" ) );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "shader/unshaded") );
+
+ if (!shader.is_null()) {
+
+ shader->get_param_list(p_list);
+ }
+
+}
+
+void CanvasItemMaterial::set_shader(const Ref<Shader>& p_shader) {
+
+ ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_CANVAS_ITEM);
+#ifdef TOOLS_ENABLED
+
+ if (shader.is_valid()) {
+ shader->disconnect("changed",this,"_shader_changed");
+ }
+#endif
+ shader=p_shader;
+
+#ifdef TOOLS_ENABLED
+
+ if (shader.is_valid()) {
+ shader->connect("changed",this,"_shader_changed");
+ }
+#endif
+
+ RID rid;
+ if (shader.is_valid())
+ rid=shader->get_rid();
+
+ VS::get_singleton()->canvas_item_material_set_shader(material,rid);
+ _change_notify(); //properties for shader exposed
+ emit_changed();
+}
+
+Ref<Shader> CanvasItemMaterial::get_shader() const{
+
+ return shader;
+}
+
+void CanvasItemMaterial::set_shader_param(const StringName& p_param,const Variant& p_value){
+
+ VS::get_singleton()->canvas_item_material_set_shader_param(material,p_param,p_value);
+}
+
+Variant CanvasItemMaterial::get_shader_param(const StringName& p_param) const{
+
+ return VS::get_singleton()->canvas_item_material_get_shader_param(material,p_param);
+}
+
+void CanvasItemMaterial::_shader_changed() {
+
+
+}
+
+RID CanvasItemMaterial::get_rid() const {
+
+ return material;
+}
+
+void CanvasItemMaterial::set_unshaded(bool p_unshaded) {
+
+ unshaded=p_unshaded;
+ VS::get_singleton()->canvas_item_material_set_unshaded(material,p_unshaded);
+}
+
+bool CanvasItemMaterial::is_unshaded() const{
+
+ return unshaded;
+}
+
+void CanvasItemMaterial::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_shader","shader:Shader"),&CanvasItemMaterial::set_shader);
+ ObjectTypeDB::bind_method(_MD("get_shader:Shader"),&CanvasItemMaterial::get_shader);
+ ObjectTypeDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param);
+ ObjectTypeDB::bind_method(_MD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param);
+ ObjectTypeDB::bind_method(_MD("set_unshaded","unshaded"),&CanvasItemMaterial::set_unshaded);
+ ObjectTypeDB::bind_method(_MD("is_unshaded"),&CanvasItemMaterial::is_unshaded);
+
+}
+
+void CanvasItemMaterial::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+
+ String f = p_function.operator String();
+ if ((f=="get_shader_param" || f=="set_shader_param") && p_idx==0) {
+
+ if (shader.is_valid()) {
+ List<PropertyInfo> pl;
+ shader->get_param_list(&pl);
+ for (List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
+ r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\"");
+ }
+ }
+ }
+ Resource::get_argument_options(p_function,p_idx,r_options);
+}
+
+CanvasItemMaterial::CanvasItemMaterial() {
+
+ material=VS::get_singleton()->canvas_item_material_create();
+ unshaded=false;
+}
+
+CanvasItemMaterial::~CanvasItemMaterial(){
+
+ VS::get_singleton()->free(material);
+}
+
+
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////
+
+
+
bool CanvasItem::is_visible() const {
if (!is_inside_tree())
@@ -730,110 +915,94 @@ bool CanvasItem::is_draw_behind_parent_enabled() const{
return behind;
}
-void CanvasItem::set_shader(const Ref<Shader>& p_shader) {
-
- ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_CANVAS_ITEM);
-
-#ifdef TOOLS_ENABLED
-
- if (shader.is_valid()) {
- shader->disconnect("changed",this,"_shader_changed");
- }
-#endif
- shader=p_shader;
-
-#ifdef TOOLS_ENABLED
+void CanvasItem::set_material(const Ref<CanvasItemMaterial>& p_material) {
- if (shader.is_valid()) {
- shader->connect("changed",this,"_shader_changed");
- }
-#endif
+ material=p_material;
RID rid;
- if (shader.is_valid())
- rid=shader->get_rid();
- VS::get_singleton()->canvas_item_set_shader(canvas_item,rid);
- _change_notify(); //properties for shader exposed
+ if (material.is_valid())
+ rid=material->get_rid();
+ VS::get_singleton()->canvas_item_set_material(canvas_item,rid);
+ _change_notify(); //properties for material exposed
}
-void CanvasItem::set_use_parent_shader(bool p_use_parent_shader) {
+void CanvasItem::set_use_parent_material(bool p_use_parent_material) {
- use_parent_shader=p_use_parent_shader;
- VS::get_singleton()->canvas_item_set_use_parent_shader(canvas_item,p_use_parent_shader);
+ use_parent_material=p_use_parent_material;
+ VS::get_singleton()->canvas_item_set_use_parent_material(canvas_item,p_use_parent_material);
}
-bool CanvasItem::get_use_parent_shader() const{
+bool CanvasItem::get_use_parent_material() const{
- return use_parent_shader;
+ return use_parent_material;
}
-Ref<Shader> CanvasItem::get_shader() const{
+Ref<CanvasItemMaterial> CanvasItem::get_material() const{
- return shader;
+ return material;
}
-void CanvasItem::set_shader_param(const StringName& p_param,const Variant& p_value) {
- VS::get_singleton()->canvas_item_set_shader_param(canvas_item,p_param,p_value);
-}
+InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const {
-Variant CanvasItem::get_shader_param(const StringName& p_param) const {
+ ERR_FAIL_COND_V(!is_inside_tree(),p_event);
- return VS::get_singleton()->canvas_item_get_shader_param(canvas_item,p_param);
-}
+ InputEvent ev = p_event;
-bool CanvasItem::_set(const StringName& p_name, const Variant& p_value) {
+ Matrix32 local_matrix = (get_canvas_transform() * get_global_transform()).affine_inverse();
- if (shader.is_valid()) {
- StringName pr = shader->remap_param(p_name);
- if (pr) {
- set_shader_param(pr,p_value);
- return true;
- }
- }
- return false;
-}
+ switch(ev.type) {
-bool CanvasItem::_get(const StringName& p_name,Variant &r_ret) const{
+ case InputEvent::MOUSE_BUTTON: {
- if (shader.is_valid()) {
- StringName pr = shader->remap_param(p_name);
- if (pr) {
- r_ret=get_shader_param(pr);
- return true;
- }
- }
- return false;
-
-}
-void CanvasItem::_get_property_list( List<PropertyInfo> *p_list) const{
-
- if (shader.is_valid()) {
- shader->get_param_list(p_list);
- }
-}
-
-#ifdef TOOLS_ENABLED
-void CanvasItem::_shader_changed() {
+ Vector2 g = local_matrix.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
+ Vector2 l = local_matrix.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y));
+ ev.mouse_button.x=l.x;
+ ev.mouse_button.y=l.y;
+ ev.mouse_button.global_x=g.x;
+ ev.mouse_button.global_y=g.y;
- _change_notify();
-}
-#endif
+ } break;
+ case InputEvent::MOUSE_MOTION: {
+
+ Vector2 g = local_matrix.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
+ Vector2 l = local_matrix.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
+ Vector2 r = local_matrix.basis_xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
+ Vector2 s = local_matrix.basis_xform(Vector2(ev.mouse_motion.speed_x,ev.mouse_motion.speed_y));
+ ev.mouse_motion.x=l.x;
+ ev.mouse_motion.y=l.y;
+ ev.mouse_motion.global_x=g.x;
+ ev.mouse_motion.global_y=g.y;
+ ev.mouse_motion.relative_x=r.x;
+ ev.mouse_motion.relative_y=r.y;
+ ev.mouse_motion.speed_x=s.x;
+ ev.mouse_motion.speed_y=s.y;
-void CanvasItem::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+ } break;
+ case InputEvent::SCREEN_TOUCH: {
- if (p_idx==0 && shader.is_valid() && (p_function.operator String()=="get_shader_param" || p_function.operator String()=="set_shader_param")) {
- List<PropertyInfo> pl;
- shader->get_param_list(&pl);
- for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
- r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\"");
- }
+ Vector2 t = local_matrix.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y));
+ ev.screen_touch.x=t.x;
+ ev.screen_touch.y=t.y;
- return;
+ } break;
+ case InputEvent::SCREEN_DRAG: {
+
+
+ Vector2 t = local_matrix.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y));
+ Vector2 r = local_matrix.basis_xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
+ Vector2 s = local_matrix.basis_xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
+ ev.screen_drag.x=t.x;
+ ev.screen_drag.y=t.y;
+ ev.screen_drag.relative_x=r.x;
+ ev.screen_drag.relative_y=r.y;
+ ev.screen_drag.speed_x=s.x;
+ ev.screen_drag.speed_y=s.y;
+ } break;
}
- Node::get_argument_options(p_function,p_idx,r_options);
+ return ev;
}
@@ -880,9 +1049,6 @@ void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top);
-#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method(_MD("_shader_changed"),&CanvasItem::_shader_changed);
-#endif
//ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
ObjectTypeDB::bind_method(_MD("draw_line","from","to","color","width"),&CanvasItem::draw_line,DEFVAL(1.0));
@@ -901,20 +1067,21 @@ void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform);
ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
ObjectTypeDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform);
+ ObjectTypeDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas);
ObjectTypeDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
ObjectTypeDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
+ ObjectTypeDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform);
ObjectTypeDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas);
ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
//ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);
- ObjectTypeDB::bind_method(_MD("set_shader","shader"),&CanvasItem::set_shader);
- ObjectTypeDB::bind_method(_MD("get_shader"),&CanvasItem::get_shader);
- ObjectTypeDB::bind_method(_MD("set_use_parent_shader","enable"),&CanvasItem::set_use_parent_shader);
- ObjectTypeDB::bind_method(_MD("get_use_parent_shader"),&CanvasItem::get_use_parent_shader);
+ ObjectTypeDB::bind_method(_MD("set_material","material:CanvasItemMaterial"),&CanvasItem::set_material);
+ ObjectTypeDB::bind_method(_MD("get_material:CanvasItemMaterial"),&CanvasItem::get_material);
- ObjectTypeDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItem::set_shader_param);
- ObjectTypeDB::bind_method(_MD("get_shader_param","param"),&CanvasItem::get_shader_param);
+ ObjectTypeDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
+ ObjectTypeDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
+ ObjectTypeDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local);
BIND_VMETHOD(MethodInfo("_draw"));
@@ -926,8 +1093,8 @@ void CanvasItem::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/light_mask",PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"),_SCS("get_light_mask") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"shader/shader",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph"), _SCS("set_shader"),_SCS("get_shader") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"shader/use_parent"), _SCS("set_use_parent_shader"),_SCS("get_use_parent_shader") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material/material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"material/use_parent"), _SCS("set_use_parent_material"),_SCS("get_use_parent_material") );
//exporting these two things doesn't really make much sense i think
//ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
//ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));
@@ -1004,7 +1171,7 @@ CanvasItem::CanvasItem() : xform_change(this) {
block_transform_notify=false;
// viewport=NULL;
canvas_layer=NULL;
- use_parent_shader=false;
+ use_parent_material=false;
global_invalid=true;
light_mask=1;
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 2441d205ce..c43642a8ec 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -40,6 +40,41 @@ class Font;
class StyleBox;
+class CanvasItemMaterial : public Resource{
+
+ OBJ_TYPE(CanvasItemMaterial,Resource);
+ RID material;
+ Ref<Shader> shader;
+ bool unshaded;
+
+protected:
+
+ bool _set(const StringName& p_name, const Variant& p_value);
+ bool _get(const StringName& p_name,Variant &r_ret) const;
+ void _get_property_list( List<PropertyInfo> *p_list) const;
+
+ void _shader_changed();
+ static void _bind_methods();
+
+ void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+
+public:
+
+ void set_shader(const Ref<Shader>& p_shader);
+ Ref<Shader> get_shader() const;
+
+ void set_shader_param(const StringName& p_param,const Variant& p_value);
+ Variant get_shader_param(const StringName& p_param) const;
+
+ void set_unshaded(bool p_unshaded);
+ bool is_unshaded() const;
+
+ virtual RID get_rid() const;
+ CanvasItemMaterial();
+ ~CanvasItemMaterial();
+};
+
+
class CanvasItem : public Node {
OBJ_TYPE( CanvasItem, Node );
@@ -81,9 +116,9 @@ private:
bool drawing;
bool block_transform_notify;
bool behind;
- bool use_parent_shader;
+ bool use_parent_material;
- Ref<Shader> shader;
+ Ref<CanvasItemMaterial> material;
mutable Matrix32 global_transform;
mutable bool global_invalid;
@@ -104,9 +139,6 @@ private:
void _queue_sort_children();
void _sort_children();
-#ifdef TOOLS_ENABLED
- void _shader_changed();
-#endif
void _notify_transform(CanvasItem *p_node);
void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); }
@@ -114,11 +146,6 @@ private:
protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
-
-
_FORCE_INLINE_ void _notify_transform() { if (!is_inside_tree()) return; _notify_transform(this); if (!block_transform_notify) notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); }
void item_rect_changed();
@@ -216,16 +243,13 @@ public:
RID get_canvas() const;
Ref<World2D> get_world_2d() const;
- void set_shader(const Ref<Shader>& p_shader);
- Ref<Shader> get_shader() const;
+ void set_material(const Ref<CanvasItemMaterial>& p_material);
+ Ref<CanvasItemMaterial> get_material() const;
- void set_use_parent_shader(bool p_use_parent_shader);
- bool get_use_parent_shader() const;
+ void set_use_parent_material(bool p_use_parent_material);
+ bool get_use_parent_material() const;
- void set_shader_param(const StringName& p_param,const Variant& p_value);
- Variant get_shader_param(const StringName& p_param) const;
-
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+ InputEvent make_input_local(const InputEvent& pevent) const;
CanvasItem();
~CanvasItem();
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 3b859d9366..a883fee103 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -28,6 +28,7 @@
/*************************************************************************/
#include "collision_object_2d.h"
#include "servers/physics_2d_server.h"
+#include "scene/scene_string_names.h"
void CollisionObject2D::_update_shapes_from_children() {
@@ -58,9 +59,15 @@ void CollisionObject2D::_notification(int p_what) {
} else
Physics2DServer::get_singleton()->body_set_space(rid,space);
+ _update_pickable();
+
//get space
}
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+
+ _update_pickable();
+ } break;
case NOTIFICATION_TRANSFORM_CHANGED: {
if (area)
@@ -166,6 +173,57 @@ void CollisionObject2D::_get_property_list( List<PropertyInfo> *p_list) const {
}
}
+
+void CollisionObject2D::set_pickable(bool p_enabled) {
+
+ if (pickable==p_enabled)
+ return;
+
+ pickable=p_enabled;
+ _update_pickable();
+}
+
+bool CollisionObject2D::is_pickable() const {
+
+ return pickable;
+}
+
+void CollisionObject2D::_input_event(Node *p_viewport, const InputEvent& p_input_event, int p_shape) {
+
+ if (get_script_instance()) {
+ get_script_instance()->call(SceneStringNames::get_singleton()->_input_event,p_viewport,p_input_event,p_shape);
+ }
+ emit_signal(SceneStringNames::get_singleton()->input_event,p_viewport,p_input_event,p_shape);
+}
+
+void CollisionObject2D::_mouse_enter() {
+
+ if (get_script_instance()) {
+ get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter);
+ }
+ emit_signal(SceneStringNames::get_singleton()->mouse_enter);
+}
+
+
+void CollisionObject2D::_mouse_exit() {
+
+ if (get_script_instance()) {
+ get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
+ }
+ emit_signal(SceneStringNames::get_singleton()->mouse_exit);
+
+}
+
+void CollisionObject2D::_update_pickable() {
+ if (!is_inside_tree())
+ return;
+ bool pickable = this->pickable && is_inside_tree() && is_visible();
+ if (area)
+ Physics2DServer::get_singleton()->area_set_pickable(rid,pickable);
+ else
+ Physics2DServer::get_singleton()->body_set_pickable(rid,pickable);
+}
+
void CollisionObject2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Matrix32()));
@@ -180,6 +238,17 @@ void CollisionObject2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("clear_shapes"),&CollisionObject2D::clear_shapes);
ObjectTypeDB::bind_method(_MD("get_rid"),&CollisionObject2D::get_rid);
+ ObjectTypeDB::bind_method(_MD("set_pickable","enabled"),&CollisionObject2D::set_pickable);
+ ObjectTypeDB::bind_method(_MD("is_pickable"),&CollisionObject2D::is_pickable);
+
+ BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::OBJECT,"viewport"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::INT,"shape_idx")));
+
+ ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::OBJECT,"viewport"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::INT,"shape_idx")));
+ ADD_SIGNAL( MethodInfo("mouse_enter"));
+ ADD_SIGNAL( MethodInfo("mouse_exit"));
+
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input/pickable"),_SCS("set_pickable"),_SCS("is_pickable"));
+
}
@@ -262,7 +331,9 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
rid=p_rid;
area=p_area;
+ pickable=true;
if (p_area) {
+
Physics2DServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID());
} else {
Physics2DServer::get_singleton()->body_attach_object_instance_ID(rid,get_instance_ID());
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index 4a529ce062..393973ce90 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -38,6 +38,7 @@ class CollisionObject2D : public Node2D {
bool area;
RID rid;
+ bool pickable;
struct ShapeData {
Matrix32 xform;
@@ -66,9 +67,17 @@ protected:
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;
static void _bind_methods();
+
+ void _update_pickable();
+friend class Viewport;
+ void _input_event(Node *p_viewport, const InputEvent& p_input_event, int p_shape);
+ void _mouse_enter();
+ void _mouse_exit();
+
public:
+
void add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform=Matrix32());
int get_shape_count() const;
void set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape);
@@ -80,6 +89,9 @@ public:
void remove_shape(int p_shape_idx);
void clear_shapes();
+ void set_pickable(bool p_enabled);
+ bool is_pickable() const;
+
_FORCE_INLINE_ RID get_rid() const { return rid; }
CollisionObject2D();
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index cea8c06d3f..4abb7e5436 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_texture_scale( float p_scale) {
+
+ _scale=p_scale;
+ VS::get_singleton()->canvas_light_set_scale(canvas_light,_scale);
+ item_rect_changed();
+
+}
+
+
+float Light2D::get_texture_scale() const {
+
+ return _scale;
+}
+
void Light2D::set_z_range_min( int p_min_z) {
z_min=p_min_z;
@@ -148,6 +166,18 @@ int Light2D::get_item_mask() const {
return item_mask;
}
+void Light2D::set_item_shadow_mask( int p_mask) {
+
+ item_shadow_mask=p_mask;
+ VS::get_singleton()->canvas_light_set_item_shadow_mask(canvas_light,item_shadow_mask);
+
+}
+
+int Light2D::get_item_shadow_mask() const {
+
+ return item_shadow_mask;
+}
+
void Light2D::set_subtract_mode( bool p_enable ) {
subtract_mode=p_enable;
@@ -170,6 +200,29 @@ bool Light2D::is_shadow_enabled() const {
return shadow;
}
+void Light2D::set_shadow_buffer_size( int p_size ) {
+
+ shadow_buffer_size=p_size;
+ VS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light,shadow_buffer_size);
+}
+
+int Light2D::get_shadow_buffer_size() const {
+
+ return shadow_buffer_size;
+}
+
+void Light2D::set_shadow_esm_multiplier( float p_multiplier) {
+
+ shadow_esm_multiplier=p_multiplier;
+ VS::get_singleton()->canvas_light_set_shadow_esm_multiplier(canvas_light,p_multiplier);
+}
+
+float Light2D::get_shadow_esm_multiplier() const{
+
+ return shadow_esm_multiplier;
+}
+
+
void Light2D::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
@@ -207,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_texture_scale","texture_scale"),&Light2D::set_texture_scale);
+ ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Light2D::get_texture_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);
@@ -223,24 +280,37 @@ void Light2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_item_mask","item_mask"),&Light2D::set_item_mask);
ObjectTypeDB::bind_method(_MD("get_item_mask"),&Light2D::get_item_mask);
+ ObjectTypeDB::bind_method(_MD("set_item_shadow_mask","item_shadow_mask"),&Light2D::set_item_shadow_mask);
+ ObjectTypeDB::bind_method(_MD("get_item_shadow_mask"),&Light2D::get_item_shadow_mask);
+
ObjectTypeDB::bind_method(_MD("set_subtract_mode","enable"),&Light2D::set_subtract_mode);
ObjectTypeDB::bind_method(_MD("get_subtract_mode"),&Light2D::get_subtract_mode);
ObjectTypeDB::bind_method(_MD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled);
ObjectTypeDB::bind_method(_MD("is_shadow_enabled"),&Light2D::is_shadow_enabled);
+ ObjectTypeDB::bind_method(_MD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size);
+ ObjectTypeDB::bind_method(_MD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size);
+
+ ObjectTypeDB::bind_method(_MD("set_shadow_esm_multiplier","multiplier"),&Light2D::set_shadow_esm_multiplier);
+ ObjectTypeDB::bind_method(_MD("get_shadow_esm_multiplier"),&Light2D::get_shadow_esm_multiplier);
+
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,"texture_offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
+ 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::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"height"),_SCS("set_height"),_SCS("get_height"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"z_range_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,"z_range_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,"layer_range_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"layer_range_max",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_max"),_SCS("get_layer_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_mask"),_SCS("get_item_mask"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"subtract"),_SCS("set_subtract_mode"),_SCS("get_subtract_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow_enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height"),_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"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_max",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_max"),_SCS("get_layer_range_max"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_mask"),_SCS("get_item_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow/enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),_SCS("set_shadow_buffer_size"),_SCS("get_shadow_buffer_size"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow/esm_multiplier",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_esm_multiplier"),_SCS("get_shadow_esm_multiplier"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_shadow_mask"),_SCS("get_item_shadow_mask"));
}
@@ -252,12 +322,16 @@ Light2D::Light2D() {
shadow=false;
color=Color(1,1,1);
height=0;
+ _scale=1.0;
z_min=-1024;
z_max=1024;
layer_min=0;
layer_max=0;
item_mask=1;
+ item_shadow_mask=1;
subtract_mode=false;
+ shadow_buffer_size=2048;
+ shadow_esm_multiplier=80;
}
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index dbfd233d39..6cfb055fa9 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -12,11 +12,15 @@ private:
bool shadow;
Color color;
float height;
+ float _scale;
int z_min;
int z_max;
int layer_min;
int layer_max;
int item_mask;
+ int item_shadow_mask;
+ int shadow_buffer_size;
+ float shadow_esm_multiplier;
bool subtract_mode;
Ref<Texture> texture;
Vector2 texture_offset;
@@ -47,6 +51,9 @@ public:
void set_height( float p_height);
float get_height() const;
+ void set_texture_scale( float p_scale);
+ float get_texture_scale() const;
+
void set_z_range_min( int p_min_z);
int get_z_range_min() const;
@@ -62,12 +69,21 @@ public:
void set_item_mask( int p_mask);
int get_item_mask() const;
+ void set_item_shadow_mask( int p_mask);
+ int get_item_shadow_mask() const;
+
void set_subtract_mode( bool p_enable );
bool get_subtract_mode() const;
void set_shadow_enabled( bool p_enabled);
bool is_shadow_enabled() const;
+ void set_shadow_buffer_size( int p_size );
+ int get_shadow_buffer_size() const;
+
+ void set_shadow_esm_multiplier( float p_multiplier);
+ float get_shadow_esm_multiplier() const;
+
virtual Rect2 get_item_rect() const;
Light2D();
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
new file mode 100644
index 0000000000..6ebd499f71
--- /dev/null
+++ b/scene/2d/light_occluder_2d.cpp
@@ -0,0 +1,202 @@
+#include "light_occluder_2d.h"
+
+
+void OccluderPolygon2D::set_polygon(const DVector<Vector2>& p_polygon) {
+
+ polygon=p_polygon;
+ VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,p_polygon,closed);
+ emit_changed();
+}
+
+DVector<Vector2> OccluderPolygon2D::get_polygon() const{
+
+ return polygon;
+}
+
+void OccluderPolygon2D::set_closed(bool p_closed) {
+
+ if (closed==p_closed)
+ return;
+ closed=p_closed;
+ if (polygon.size())
+ VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,polygon,closed);
+ emit_changed();
+}
+
+bool OccluderPolygon2D::is_closed() const{
+
+ return closed;
+}
+
+void OccluderPolygon2D::set_cull_mode(CullMode p_mode){
+
+ cull=p_mode;
+ VS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon,VS::CanvasOccluderPolygonCullMode(p_mode));
+}
+
+OccluderPolygon2D::CullMode OccluderPolygon2D::get_cull_mode() const{
+
+ return cull;
+}
+
+
+RID OccluderPolygon2D::get_rid() const {
+
+ return occ_polygon;
+}
+
+void OccluderPolygon2D::_bind_methods() {
+
+
+ ObjectTypeDB::bind_method(_MD("set_closed","closed"),&OccluderPolygon2D::set_closed);
+ ObjectTypeDB::bind_method(_MD("is_closed"),&OccluderPolygon2D::is_closed);
+
+ ObjectTypeDB::bind_method(_MD("set_cull_mode","cull_mode"),&OccluderPolygon2D::set_cull_mode);
+ ObjectTypeDB::bind_method(_MD("get_cull_mode"),&OccluderPolygon2D::get_cull_mode);
+
+ ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon);
+ ObjectTypeDB::bind_method(_MD("get_polygon"),&OccluderPolygon2D::get_polygon);
+
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"closed"),_SCS("set_closed"),_SCS("is_closed"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mode",PROPERTY_HINT_ENUM,"Disabled,ClockWise,CounterClockWise"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
+
+ BIND_CONSTANT(CULL_DISABLED);
+ BIND_CONSTANT(CULL_CLOCKWISE);
+ BIND_CONSTANT(CULL_COUNTER_CLOCKWISE);
+}
+
+
+OccluderPolygon2D::OccluderPolygon2D() {
+
+ occ_polygon=VS::get_singleton()->canvas_occluder_polygon_create();
+ closed=true;
+ cull=CULL_DISABLED;
+}
+
+OccluderPolygon2D::~OccluderPolygon2D() {
+
+ VS::get_singleton()->free(occ_polygon);
+}
+
+#ifdef DEBUG_ENABLED
+void LightOccluder2D::_poly_changed() {
+
+ update();
+}
+#endif
+
+
+void LightOccluder2D::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_CANVAS) {
+
+ VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,get_canvas());
+ VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
+
+ }
+ if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
+
+ VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
+ }
+
+ if (p_what==NOTIFICATION_DRAW) {
+
+ if (get_tree()->is_editor_hint()) {
+
+ if (occluder_polygon.is_valid()) {
+
+ DVector<Vector2> poly = occluder_polygon->get_polygon();
+
+ if (poly.size()) {
+ if (occluder_polygon->is_closed()) {
+ Vector<Color> color;
+ color.push_back(Color(0,0,0,0.6));
+ draw_polygon(Variant(poly),color);
+ } else {
+
+ int ps=poly.size();
+ DVector<Vector2>::Read r = poly.read();
+ for(int i=0;i<ps-1;i++) {
+
+ draw_line(r[i],r[i+1],Color(0,0,0,0.6),3);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ if (p_what==NOTIFICATION_EXIT_CANVAS) {
+
+ VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,RID());
+ }
+
+
+}
+
+void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D>& p_polygon) {
+
+#ifdef DEBUG_ENABLED
+ if (occluder_polygon.is_valid())
+ occluder_polygon->disconnect("changed",this,"_poly_changed");
+#endif
+ occluder_polygon=p_polygon;
+
+ if (occluder_polygon.is_valid())
+ VS::get_singleton()->canvas_light_occluder_set_polygon(occluder,occluder_polygon->get_rid());
+ else
+ VS::get_singleton()->canvas_light_occluder_set_polygon(occluder,RID());
+
+#ifdef DEBUG_ENABLED
+ if (occluder_polygon.is_valid())
+ occluder_polygon->connect("changed",this,"_poly_changed");
+ update();
+#endif
+
+}
+
+Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const {
+
+ return occluder_polygon;
+}
+
+void LightOccluder2D::set_occluder_light_mask(int p_mask) {
+
+ mask=p_mask;
+ VS::get_singleton()->canvas_light_occluder_set_light_mask(occluder,mask);
+}
+
+int LightOccluder2D::get_occluder_light_mask() const{
+
+ return mask;
+}
+
+void LightOccluder2D::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_occluder_polygon","polygon:OccluderPolygon2D"),&LightOccluder2D::set_occluder_polygon);
+ ObjectTypeDB::bind_method(_MD("get_occluder_polygon:OccluderPolygon2D"),&LightOccluder2D::get_occluder_polygon);
+
+ ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&LightOccluder2D::set_occluder_light_mask);
+ ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&LightOccluder2D::get_occluder_light_mask);
+
+#ifdef DEBUG_ENABLED
+ ObjectTypeDB::bind_method("_poly_changed",&LightOccluder2D::_poly_changed);
+#endif
+
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"),_SCS("set_occluder_polygon"),_SCS("get_occluder_polygon"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+}
+
+LightOccluder2D::LightOccluder2D() {
+
+ occluder=VS::get_singleton()->canvas_light_occluder_create();
+ mask=1;
+}
+
+LightOccluder2D::~LightOccluder2D() {
+
+ VS::get_singleton()->free(occluder);
+}
+
diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h
new file mode 100644
index 0000000000..0343e3697e
--- /dev/null
+++ b/scene/2d/light_occluder_2d.h
@@ -0,0 +1,73 @@
+#ifndef LIGHTOCCLUDER2D_H
+#define LIGHTOCCLUDER2D_H
+
+#include "scene/2d/node_2d.h"
+
+class OccluderPolygon2D : public Resource {
+
+ OBJ_TYPE(OccluderPolygon2D,Resource);
+public:
+
+ enum CullMode {
+ CULL_DISABLED,
+ CULL_CLOCKWISE,
+ CULL_COUNTER_CLOCKWISE
+ };
+private:
+
+
+ RID occ_polygon;
+ DVector<Vector2> polygon;
+ bool closed;
+ CullMode cull;
+
+protected:
+
+ static void _bind_methods();
+public:
+
+ void set_polygon(const DVector<Vector2>& p_polygon);
+ DVector<Vector2> get_polygon() const;
+
+ void set_closed(bool p_closed);
+ bool is_closed() const;
+
+ void set_cull_mode(CullMode p_mode);
+ CullMode get_cull_mode() const;
+
+ virtual RID get_rid() const;
+ OccluderPolygon2D();
+ ~OccluderPolygon2D();
+
+};
+
+VARIANT_ENUM_CAST(OccluderPolygon2D::CullMode);
+
+class LightOccluder2D : public Node2D {
+ OBJ_TYPE(LightOccluder2D,Node2D);
+
+ RID occluder;
+ bool enabled;
+ int mask;
+ Ref<OccluderPolygon2D> occluder_polygon;
+
+#ifdef DEBUG_ENABLED
+ void _poly_changed();
+#endif
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void set_occluder_polygon(const Ref<OccluderPolygon2D>& p_polygon);
+ Ref<OccluderPolygon2D> get_occluder_polygon() const;
+
+ void set_occluder_light_mask(int p_mask);
+ int get_occluder_light_mask() const;
+
+ LightOccluder2D();
+ ~LightOccluder2D();
+};
+
+#endif // LIGHTOCCLUDER2D_H
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 36b6b220b3..0b098f0cad 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -65,7 +65,7 @@ void Node2D::edit_set_state(const Variant& p_state) {
pos = state[0];
angle = state[1];
- scale = state[2];
+ _scale = state[2];
_update_transform();
_change_notify("transform/rot");
_change_notify("transform/scale");
@@ -93,11 +93,11 @@ void Node2D::edit_set_rect(const Rect2& p_edit_rect) {
Point2 new_pos = p_edit_rect.pos + p_edit_rect.size*zero_offset;//p_edit_rect.pos - r.pos;
Matrix32 postxf;
- postxf.set_rotation_and_scale(angle,scale);
+ postxf.set_rotation_and_scale(angle,_scale);
new_pos = postxf.xform(new_pos);
pos+=new_pos;
- scale*=new_scale;
+ _scale*=new_scale;
_update_transform();
_change_notify("transform/scale");
@@ -118,14 +118,14 @@ void Node2D::_update_xform_values() {
pos=_mat.elements[2];
angle=_mat.get_rotation();
- scale=_mat.get_scale();
+ _scale=_mat.get_scale();
_xform_dirty=false;
}
void Node2D::_update_transform() {
Matrix32 mat(angle,pos);
- _mat.set_rotation_and_scale(angle,scale);
+ _mat.set_rotation_and_scale(angle,_scale);
_mat.elements[2]=pos;
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),_mat);
@@ -161,11 +161,11 @@ void Node2D::set_scale(const Size2& p_scale) {
if (_xform_dirty)
((Node2D*)this)->_update_xform_values();
- scale=p_scale;
- if (scale.x==0)
- scale.x=CMP_EPSILON;
- if (scale.y==0)
- scale.y=CMP_EPSILON;
+ _scale=p_scale;
+ if (_scale.x==0)
+ _scale.x=CMP_EPSILON;
+ if (_scale.y==0)
+ _scale.y=CMP_EPSILON;
_update_transform();
_change_notify("transform/scale");
@@ -187,7 +187,7 @@ Size2 Node2D::get_scale() const {
if (_xform_dirty)
((Node2D*)this)->_update_xform_values();
- return scale;
+ return _scale;
}
void Node2D::_set_rotd(float p_angle) {
@@ -224,11 +224,27 @@ Rect2 Node2D::get_item_rect() const {
return Rect2(Point2(-32,-32),Size2(64,64));
}
-void Node2D::rotate(float p_degrees) {
+void Node2D::rotate(float p_radians) {
- set_rot( get_rot() + p_degrees);
+ set_rot( get_rot() + p_radians);
}
+void Node2D::translate(const Vector2& p_amount) {
+
+ set_pos( get_pos() + p_amount );
+}
+
+void Node2D::global_translate(const Vector2& p_amount) {
+
+ set_global_pos( get_global_pos() + p_amount );
+}
+
+void Node2D::scale(const Vector2& p_amount) {
+
+ set_scale( get_scale() * p_amount );
+}
+
+
void Node2D::move_x(float p_delta,bool p_scaled){
Matrix32 t = get_transform();
@@ -345,9 +361,12 @@ void Node2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_rot"),&Node2D::get_rot);
ObjectTypeDB::bind_method(_MD("get_scale"),&Node2D::get_scale);
- ObjectTypeDB::bind_method(_MD("rotate","degrees"),&Node2D::rotate);
+ ObjectTypeDB::bind_method(_MD("rotate","radians"),&Node2D::rotate);
ObjectTypeDB::bind_method(_MD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("translate","offset"),&Node2D::translate);
+ ObjectTypeDB::bind_method(_MD("global_translate","offset"),&Node2D::global_translate);
+ ObjectTypeDB::bind_method(_MD("scale","ratio"),&Node2D::scale);
ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Node2D::set_global_pos);
ObjectTypeDB::bind_method(_MD("get_global_pos"),&Node2D::get_global_pos);
@@ -379,7 +398,7 @@ Node2D::Node2D() {
angle=0;
- scale=Vector2(1,1);
+ _scale=Vector2(1,1);
_xform_dirty=false;
z=0;
z_relative=true;
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 7b059008c2..39a1061195 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -37,7 +37,7 @@ class Node2D : public CanvasItem {
Point2 pos;
float angle;
- Size2 scale;
+ Size2 _scale;
int z;
bool z_relative;
@@ -72,9 +72,12 @@ public:
void set_rot(float p_angle);
void set_scale(const Size2& p_scale);
- void rotate(float p_degrees);
+ void rotate(float p_radians);
void move_x(float p_delta,bool p_scaled=false);
void move_y(float p_delta,bool p_scaled=false);
+ void translate(const Vector2& p_amount);
+ void global_translate(const Vector2& p_amount);
+ void scale(const Vector2& p_amount);
Point2 get_pos() const;
float get_rot() const;
@@ -96,6 +99,7 @@ public:
Matrix32 get_relative_transform(const Node *p_parent) const;
+
Matrix32 get_transform() const;
Node2D();
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 6e2cf5954b..c9dd92ff3d 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -1077,13 +1077,18 @@ void Particles2D::_bind_methods() {
BIND_CONSTANT( PARAM_SPREAD );
BIND_CONSTANT( PARAM_LINEAR_VELOCITY );
BIND_CONSTANT( PARAM_SPIN_VELOCITY );
+ BIND_CONSTANT( PARAM_ORBIT_VELOCITY );
BIND_CONSTANT( PARAM_GRAVITY_DIRECTION );
BIND_CONSTANT( PARAM_GRAVITY_STRENGTH );
BIND_CONSTANT( PARAM_RADIAL_ACCEL );
BIND_CONSTANT( PARAM_TANGENTIAL_ACCEL );
+ BIND_CONSTANT( PARAM_DAMPING );
+ BIND_CONSTANT( PARAM_INITIAL_ANGLE );
BIND_CONSTANT( PARAM_INITIAL_SIZE );
BIND_CONSTANT( PARAM_FINAL_SIZE );
BIND_CONSTANT( PARAM_HUE_VARIATION );
+ BIND_CONSTANT( PARAM_ANIM_SPEED_SCALE );
+ BIND_CONSTANT( PARAM_ANIM_INITIAL_POS );
BIND_CONSTANT( PARAM_MAX );
BIND_CONSTANT( MAX_COLOR_PHASES );
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 6f18325212..22dd0f01d0 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -98,6 +98,7 @@ PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject
mask=1;
set_one_way_collision_max_depth(0);
+ set_pickable(false);
}
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 75e7957cb8..2b88ee5dba 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -30,12 +30,32 @@
#include "io/marshalls.h"
#include "servers/physics_2d_server.h"
#include "method_bind_ext.inc"
+
+int TileMap::_get_quadrant_size() const {
+
+ if (y_sort_mode)
+ return 1;
+ else
+ return quadrant_size;
+}
+
void TileMap::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_TREE: {
+ Node2D *c=this;
+ while(c) {
+
+ navigation=c->cast_to<Navigation2D>();
+ if (navigation) {
+ break;
+ }
+
+ c=c->get_parent()->cast_to<Node2D>();
+ }
+
pending_update=true;
_update_dirty_quadrants();
RID space = get_world_2d()->get_space();
@@ -47,6 +67,25 @@ void TileMap::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
_update_quadrant_space(RID());
+ for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+
+ Quadrant &q=E->get();
+ if (navigation) {
+ for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+
+ navigation->navpoly_remove(E->get().id);
+ }
+ q.navpoly_ids.clear();
+ }
+
+ for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
+ VS::get_singleton()->free(E->get().id);
+ }
+ q.occluder_instances.clear();
+ }
+
+ navigation=NULL;
+
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -74,6 +113,10 @@ void TileMap::_update_quadrant_transform() {
Matrix32 global_transform = get_global_transform();
+ Matrix32 nav_rel;
+ if (navigation)
+ nav_rel = get_relative_transform(navigation);
+
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
@@ -81,6 +124,17 @@ void TileMap::_update_quadrant_transform() {
xform.set_origin( q.pos );
xform = global_transform * xform;
Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
+
+ if (navigation) {
+ for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+
+ navigation->navpoly_set_transform(E->get().id,nav_rel * E->get().xform);
+ }
+ }
+
+ for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
+ VS::get_singleton()->canvas_light_occluder_set_transform(E->get().id,global_transform * E->get().xform);
+ }
}
}
@@ -161,6 +215,34 @@ bool TileMap::get_center_y() const {
return center_y;
}
+void TileMap::_fix_cell_transform(Matrix32& xform,const Cell& p_cell, const Vector2& p_offset, const Size2 &p_sc) {
+
+ Size2 s=p_sc;
+ Vector2 offset = p_offset;
+
+ if (p_cell.transpose) {
+ SWAP(xform.elements[0].x, xform.elements[0].y);
+ SWAP(xform.elements[1].x, xform.elements[1].y);
+ SWAP(offset.x, offset.y);
+ SWAP(s.x, s.y);
+ }
+ if (p_cell.flip_h) {
+ xform.elements[0].x=-xform.elements[0].x;
+ xform.elements[1].x=-xform.elements[1].x;
+ if (tile_origin==TILE_ORIGIN_TOP_LEFT)
+ offset.x=s.x-offset.x;
+ }
+ if (p_cell.flip_v) {
+ xform.elements[0].y=-xform.elements[0].y;
+ xform.elements[1].y=-xform.elements[1].y;
+ if (tile_origin==TILE_ORIGIN_TOP_LEFT)
+ offset.y=s.y-offset.y;
+ }
+ xform.elements[2].x+=offset.x;
+ xform.elements[2].y+=offset.y;
+
+}
+
void TileMap::_update_dirty_quadrants() {
if (!pending_update)
@@ -173,15 +255,42 @@ void TileMap::_update_dirty_quadrants() {
VisualServer *vs = VisualServer::get_singleton();
Physics2DServer *ps = Physics2DServer::get_singleton();
Vector2 tofs = get_cell_draw_offset();
+ Vector2 tcenter = cell_size/2;
+ Matrix32 nav_rel;
+ if (navigation)
+ nav_rel = get_relative_transform(navigation);
+
+ Vector2 qofs;
while (dirty_quadrant_list.first()) {
Quadrant &q = *dirty_quadrant_list.first()->self();
- vs->canvas_item_clear(q.canvas_item);
+ for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) {
+
+ vs->free(E->get());
+ }
+
+ q.canvas_items.clear();
+
ps->body_clear_shapes(q.body);
int shape_idx=0;
+ if (navigation) {
+ for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+
+ navigation->navpoly_remove(E->get().id);
+ }
+ q.navpoly_ids.clear();
+ }
+
+ for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
+ VS::get_singleton()->free(E->get().id);
+ }
+ q.occluder_instances.clear();
+ Ref<CanvasItemMaterial> prev_material;
+ RID prev_canvas_item;
+
for(int i=0;i<q.cells.size();i++) {
Map<PosKey,Cell>::Element *E=tile_map.find( q.cells[i] );
@@ -192,11 +301,35 @@ void TileMap::_update_dirty_quadrants() {
Ref<Texture> tex = tile_set->tile_get_texture(c.id);
Vector2 tile_ofs = tile_set->tile_get_texture_offset(c.id);
- Vector2 offset = _map_to_world(E->key().x, E->key().y) - q.pos + tofs;
+ Vector2 wofs = _map_to_world(E->key().x, E->key().y);
+ Vector2 offset = wofs - q.pos + tofs;
if (!tex.is_valid())
continue;
+ Ref<CanvasItemMaterial> mat = tile_set->tile_get_material(c.id);
+
+ RID canvas_item;
+
+ if (prev_canvas_item==RID() || prev_material!=mat) {
+
+ canvas_item=vs->canvas_item_create();
+ if (mat.is_valid())
+ vs->canvas_item_set_material(canvas_item,mat->get_rid());
+ vs->canvas_item_set_parent( canvas_item, get_canvas_item() );
+ Matrix32 xform;
+ xform.set_origin( q.pos );
+ vs->canvas_item_set_transform( canvas_item, xform );
+ q.canvas_items.push_back(canvas_item);
+
+ prev_canvas_item=canvas_item;
+ prev_material=mat;
+
+ } else {
+ canvas_item=prev_canvas_item;
+ }
+
+
Rect2 r = tile_set->tile_get_region(c.id);
Size2 s = tex->get_size();
@@ -223,12 +356,32 @@ void TileMap::_update_dirty_quadrants() {
if (c.flip_v)
rect.size.y=-rect.size.y;
+ Vector2 center_ofs;
+
+ if (tile_origin==TILE_ORIGIN_TOP_LEFT) {
+ rect.pos+=tile_ofs;
+ } else if (tile_origin==TILE_ORIGIN_CENTER) {
+ rect.pos+=tcenter;
+
+ Vector2 center = (s/2) - tile_ofs;
+ center_ofs=tcenter-(s/2);
+
+ if (c.flip_h)
+ rect.pos.x-=s.x-center.x;
+ else
+ rect.pos.x-=center.x;
+
+ if (c.flip_v)
+ rect.pos.y-=s.y-center.y;
+ else
+ rect.pos.y-=center.y;
+ }
+
- rect.pos+=tile_ofs;
if (r==Rect2()) {
- tex->draw_rect(q.canvas_item,rect,false,Color(1,1,1),c.transpose);
+ tex->draw_rect(canvas_item,rect,false,Color(1,1,1),c.transpose);
} else {
- tex->draw_rect_region(q.canvas_item,rect,r,Color(1,1,1),c.transpose);
+ tex->draw_rect_region(canvas_item,rect,r,Color(1,1,1),c.transpose);
}
Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id);
@@ -242,32 +395,48 @@ void TileMap::_update_dirty_quadrants() {
Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id);
Matrix32 xform;
xform.set_origin(offset.floor());
- if (c.transpose) {
- SWAP(xform.elements[0].x, xform.elements[0].y);
- SWAP(xform.elements[1].x, xform.elements[1].y);
- SWAP(shape_ofs.x, shape_ofs.y);
- SWAP(s.x, s.y);
- }
- if (c.flip_h) {
- xform.elements[0].x=-xform.elements[0].x;
- xform.elements[1].x=-xform.elements[1].x;
- shape_ofs.x=s.x-shape_ofs.x;
- }
- if (c.flip_v) {
- xform.elements[0].y=-xform.elements[0].y;
- xform.elements[1].y=-xform.elements[1].y;
- shape_ofs.y=s.y-shape_ofs.y;
- }
- xform.elements[2].x+=shape_ofs.x;
- xform.elements[2].y+=shape_ofs.y;
-
+ _fix_cell_transform(xform,c,shape_ofs+center_ofs,s);
ps->body_add_shape(q.body,shape->get_rid(),xform);
ps->body_set_shape_metadata(q.body,shape_idx++,Vector2(E->key().x,E->key().y));
}
}
+
+ if (navigation) {
+ Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id);
+ Vector2 npoly_ofs = tile_set->tile_get_navigation_polygon_offset(c.id);
+ Matrix32 xform;
+ xform.set_origin(offset.floor()+q.pos);
+ _fix_cell_transform(xform,c,npoly_ofs+center_ofs,s);
+
+ int pid = navigation->navpoly_create(navpoly,nav_rel * xform);
+
+ Quadrant::NavPoly np;
+ np.id=pid;
+ np.xform=xform;
+ q.navpoly_ids[E->key()]=np;
+ }
+
+
+ Ref<OccluderPolygon2D> occluder=tile_set->tile_get_light_occluder(c.id);
+ if (occluder.is_valid()) {
+
+ Vector2 occluder_ofs = tile_set->tile_get_occluder_offset(c.id);
+ Matrix32 xform;
+ xform.set_origin(offset.floor()+q.pos);
+ _fix_cell_transform(xform,c,occluder_ofs+center_ofs,s);
+
+ RID orid = VS::get_singleton()->canvas_light_occluder_create();
+ VS::get_singleton()->canvas_light_occluder_set_transform(orid,get_global_transform() * xform);
+ VS::get_singleton()->canvas_light_occluder_set_polygon(orid,occluder->get_rid());
+ VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid,get_canvas());
+ Quadrant::Occluder oc;
+ oc.xform=xform;
+ oc.id=orid;
+ q.occluder_instances[E->key()]=oc;
+ }
}
dirty_quadrant_list.remove( dirty_quadrant_list.first() );
@@ -282,10 +451,10 @@ void TileMap::_update_dirty_quadrants() {
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
- if (q.canvas_item.is_valid()) {
- VS::get_singleton()->canvas_item_raise(q.canvas_item);
- }
+ for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) {
+ VS::get_singleton()->canvas_item_raise(E->get());
+ }
}
quadrant_order_dirty=false;
@@ -308,10 +477,10 @@ void TileMap::_recompute_rect_cache() {
Rect2 r;
- r.pos=_map_to_world(E->key().x*quadrant_size, E->key().y*quadrant_size);
- r.expand_to( _map_to_world(E->key().x*quadrant_size+quadrant_size, E->key().y*quadrant_size) );
- r.expand_to( _map_to_world(E->key().x*quadrant_size+quadrant_size, E->key().y*quadrant_size+quadrant_size) );
- r.expand_to( _map_to_world(E->key().x*quadrant_size, E->key().y*quadrant_size+quadrant_size) );
+ r.pos=_map_to_world(E->key().x*_get_quadrant_size(), E->key().y*_get_quadrant_size());
+ r.expand_to( _map_to_world(E->key().x*_get_quadrant_size()+_get_quadrant_size(), E->key().y*_get_quadrant_size()) );
+ r.expand_to( _map_to_world(E->key().x*_get_quadrant_size()+_get_quadrant_size(), E->key().y*_get_quadrant_size()+_get_quadrant_size()) );
+ r.expand_to( _map_to_world(E->key().x*_get_quadrant_size(), E->key().y*_get_quadrant_size()+_get_quadrant_size()) );
if (E==quadrant_map.front())
r_total=r;
else
@@ -322,7 +491,7 @@ void TileMap::_recompute_rect_cache() {
if (r_total==Rect2()) {
rect_cache=Rect2(-10,-10,20,20);
} else {
- rect_cache=r_total.grow(MAX(cell_size.x,cell_size.y)*quadrant_size);
+ rect_cache=r_total.grow(MAX(cell_size.x,cell_size.y)*_get_quadrant_size());
}
item_rect_changed();
@@ -338,11 +507,13 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
Matrix32 xform;
//xform.set_origin(Point2(p_qk.x,p_qk.y)*cell_size*quadrant_size);
Quadrant q;
- q.pos = _map_to_world(p_qk.x*quadrant_size,p_qk.y*quadrant_size);
+ q.pos = _map_to_world(p_qk.x*_get_quadrant_size(),p_qk.y*_get_quadrant_size());
+ q.pos+=get_cell_draw_offset();
+ if (tile_origin==TILE_ORIGIN_CENTER)
+ q.pos+=cell_size/2;
+
xform.set_origin( q.pos );
- q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
- VisualServer::get_singleton()->canvas_item_set_parent( q.canvas_item, get_canvas_item() );
- VisualServer::get_singleton()->canvas_item_set_transform( q.canvas_item, xform );
+// q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC);
Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID());
Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
@@ -366,10 +537,27 @@ void TileMap::_erase_quadrant(Map<PosKey,Quadrant>::Element *Q) {
Quadrant &q=Q->get();
Physics2DServer::get_singleton()->free(q.body);
- VisualServer::get_singleton()->free(q.canvas_item);
+ for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) {
+
+ VisualServer::get_singleton()->free(E->get());
+ }
+ q.canvas_items.clear();
if (q.dirty_list.in_list())
dirty_quadrant_list.remove(&q.dirty_list);
+ if (navigation) {
+ for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+
+ navigation->navpoly_remove(E->get().id);
+ }
+ q.navpoly_ids.clear();
+ }
+
+ for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
+ VS::get_singleton()->free(E->get().id);
+ }
+ q.occluder_instances.clear();
+
quadrant_map.erase(Q);
rect_cache_dirty=true;
}
@@ -397,7 +585,7 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bo
if (!E && p_tile==INVALID_CELL)
return; //nothing to do
- PosKey qk(p_x/quadrant_size,p_y/quadrant_size);
+ PosKey qk(p_x/_get_quadrant_size(),p_y/_get_quadrant_size());
if (p_tile==INVALID_CELL) {
//erase existing
tile_map.erase(pk);
@@ -495,7 +683,7 @@ void TileMap::_recreate_quadrants() {
for (Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
- PosKey qk(E->key().x/quadrant_size,E->key().y/quadrant_size);
+ PosKey qk(E->key().x/_get_quadrant_size(),E->key().y/_get_quadrant_size());
Map<PosKey,Quadrant>::Element *Q=quadrant_map.find(qk);
if (!Q) {
@@ -511,6 +699,7 @@ void TileMap::_recreate_quadrants() {
}
+
void TileMap::_clear_quadrants() {
while (quadrant_map.size()) {
@@ -678,6 +867,20 @@ void TileMap::set_half_offset(HalfOffset p_half_offset) {
emit_signal("settings_changed");
}
+void TileMap::set_tile_origin(TileOrigin p_tile_origin) {
+
+ _clear_quadrants();
+ tile_origin=p_tile_origin;
+ _recreate_quadrants();
+ emit_signal("settings_changed");
+}
+
+TileMap::TileOrigin TileMap::get_tile_origin() const{
+
+ return tile_origin;
+}
+
+
Vector2 TileMap::get_cell_draw_offset() const {
switch(mode) {
@@ -804,6 +1007,21 @@ Vector2 TileMap::world_to_map(const Vector2& p_pos) const{
return ret.floor();
}
+void TileMap::set_y_sort_mode(bool p_enable) {
+
+ _clear_quadrants();
+ y_sort_mode=p_enable;
+ VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(),y_sort_mode);
+ _recreate_quadrants();
+ emit_signal("settings_changed");
+
+}
+
+bool TileMap::is_y_sort_mode_enabled() const {
+
+ return y_sort_mode;
+}
+
void TileMap::_bind_methods() {
@@ -829,12 +1047,18 @@ void TileMap::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size);
ObjectTypeDB::bind_method(_MD("get_quadrant_size"),&TileMap::get_quadrant_size);
+ ObjectTypeDB::bind_method(_MD("set_tile_origin","origin"),&TileMap::set_tile_origin);
+ ObjectTypeDB::bind_method(_MD("get_tile_origin"),&TileMap::get_tile_origin);
+
ObjectTypeDB::bind_method(_MD("set_center_x","enable"),&TileMap::set_center_x);
ObjectTypeDB::bind_method(_MD("get_center_x"),&TileMap::get_center_x);
ObjectTypeDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y);
ObjectTypeDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y);
+ ObjectTypeDB::bind_method(_MD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode);
+ ObjectTypeDB::bind_method(_MD("is_y_sort_mode_enabled"),&TileMap::is_y_sort_mode_enabled);
+
ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
@@ -871,6 +1095,8 @@ void TileMap::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size"));
ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"cell/custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center"),_SCS("set_tile_origin"),_SCS("get_tile_origin"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell/y_sort"),_SCS("set_y_sort_mode"),_SCS("is_y_sort_mode_enabled"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
@@ -886,6 +1112,8 @@ void TileMap::_bind_methods() {
BIND_CONSTANT( HALF_OFFSET_X );
BIND_CONSTANT( HALF_OFFSET_Y );
BIND_CONSTANT( HALF_OFFSET_DISABLED );
+ BIND_CONSTANT( TILE_ORIGIN_TOP_LEFT );
+ BIND_CONSTANT( TILE_ORIGIN_CENTER );
}
@@ -906,9 +1134,12 @@ TileMap::TileMap() {
mode=MODE_SQUARE;
half_offset=HALF_OFFSET_DISABLED;
use_kinematic=false;
+ navigation=NULL;
+ y_sort_mode=false;
fp_adjust=0.01;
fp_adjust=0.01;
+ tile_origin=TILE_ORIGIN_TOP_LEFT;
}
TileMap::~TileMap() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index fe1067fc1d..e02c4ee5bb 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -30,6 +30,7 @@
#define TILE_MAP_H
#include "scene/2d/node_2d.h"
+#include "scene/2d/navigation2d.h"
#include "scene/resources/tile_set.h"
#include "self_list.h"
#include "vset.h"
@@ -51,6 +52,12 @@ public:
HALF_OFFSET_DISABLED,
};
+ enum TileOrigin {
+ TILE_ORIGIN_TOP_LEFT,
+ TILE_ORIGIN_CENTER
+ };
+
+
private:
Ref<TileSet> tile_set;
@@ -61,6 +68,7 @@ private:
Matrix32 custom_transform;
HalfOffset half_offset;
bool use_kinematic;
+ Navigation2D *navigation;
union PosKey {
@@ -98,15 +106,29 @@ private:
struct Quadrant {
Vector2 pos;
- RID canvas_item;
+ List<RID> canvas_items;
RID body;
SelfList<Quadrant> dirty_list;
+ struct NavPoly {
+ int id;
+ Matrix32 xform;
+ };
+
+ struct Occluder {
+ RID id;
+ Matrix32 xform;
+ };
+
+
+ Map<PosKey,NavPoly> navpoly_ids;
+ Map<PosKey,Occluder> occluder_instances;
+
VSet<PosKey> cells;
- void operator=(const Quadrant& q) { pos=q.pos; canvas_item=q.canvas_item; body=q.body; cells=q.cells; }
- Quadrant(const Quadrant& q) : dirty_list(this) { pos=q.pos; canvas_item=q.canvas_item; body=q.body; cells=q.cells;}
+ void operator=(const Quadrant& q) { pos=q.pos; canvas_items=q.canvas_items; body=q.body; cells=q.cells; navpoly_ids=q.navpoly_ids; occluder_instances=q.occluder_instances; }
+ Quadrant(const Quadrant& q) : dirty_list(this) { pos=q.pos; canvas_items=q.canvas_items; body=q.body; cells=q.cells; occluder_instances=q.occluder_instances; navpoly_ids=q.navpoly_ids;}
Quadrant() : dirty_list(this) {}
};
@@ -119,11 +141,14 @@ private:
Rect2 rect_cache;
bool rect_cache_dirty;
bool quadrant_order_dirty;
+ bool y_sort_mode;
float fp_adjust;
float friction;
float bounce;
uint32_t collision_layer;
+ TileOrigin tile_origin;
+ void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc);
Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk);
void _erase_quadrant(Map<PosKey,Quadrant>::Element *Q);
@@ -135,6 +160,9 @@ private:
void _update_quadrant_transform();
void _recompute_rect_cache();
+ _FORCE_INLINE_ int _get_quadrant_size() const;
+
+
void _set_tile_data(const DVector<int>& p_data);
DVector<int> _get_tile_data() const;
@@ -195,6 +223,9 @@ public:
void set_half_offset(HalfOffset p_half_offset);
HalfOffset get_half_offset() const;
+ void set_tile_origin(TileOrigin p_tile_origin);
+ TileOrigin get_tile_origin() const;
+
void set_custom_transform(const Matrix32& p_xform);
Matrix32 get_custom_transform() const;
@@ -204,6 +235,9 @@ public:
Vector2 map_to_world(const Vector2& p_pos, bool p_ignore_ofs=false) const;
Vector2 world_to_map(const Vector2& p_pos) const;
+ void set_y_sort_mode(bool p_enable);
+ bool is_y_sort_mode_enabled() const;
+
void clear();
TileMap();
@@ -212,5 +246,6 @@ public:
VARIANT_ENUM_CAST(TileMap::Mode);
VARIANT_ENUM_CAST(TileMap::HalfOffset);
+VARIANT_ENUM_CAST(TileMap::TileOrigin);
#endif // TILE_MAP_H
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index 22534eeb0e..cd3c788b65 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -32,6 +32,7 @@
#include "scene/2d/physics_body_2d.h"
#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
+#include "particles_2d.h"
void VisibilityNotifier2D::_enter_viewport(Viewport* p_viewport) {
@@ -188,6 +189,15 @@ void VisibilityEnabler2D::_find_nodes(Node* p_node) {
}
+ if (enabler[ENABLER_PAUSE_PARTICLES]) {
+
+ Particles2D *ps = p_node->cast_to<Particles2D>();
+ if (ps) {
+ add=true;
+ }
+
+ }
+
if (add) {
p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
@@ -271,6 +281,15 @@ void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) {
}
}
+ {
+ Particles2D *ps=p_node->cast_to<Particles2D>();
+
+ if (ps) {
+
+ ps->set_emitting(p_enabled);
+ }
+ }
+
}
@@ -292,9 +311,11 @@ void VisibilityEnabler2D::_bind_methods(){
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
+ ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_particles"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES);
BIND_CONSTANT( ENABLER_FREEZE_BODIES );
BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS );
+ BIND_CONSTANT( ENABLER_PAUSE_PARTICLES );
BIND_CONSTANT( ENABLER_MAX);
}
@@ -320,3 +341,4 @@ VisibilityEnabler2D::VisibilityEnabler2D() {
}
+
diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h
index cdf52ecb27..621c470d5d 100644
--- a/scene/2d/visibility_notifier_2d.h
+++ b/scene/2d/visibility_notifier_2d.h
@@ -73,6 +73,7 @@ public:
enum Enabler {
ENABLER_PAUSE_ANIMATIONS,
ENABLER_FREEZE_BODIES,
+ ENABLER_PAUSE_PARTICLES,
ENABLER_MAX
};
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 95eafa0df4..db69182ca0 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -152,11 +152,11 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
case PROJECTION_PERSPECTIVE: {
- p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_NOEDITOR) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_NOEDITOR) );
if (keep_aspect==KEEP_WIDTH)
- p_list->push_back( PropertyInfo( Variant::REAL, "fovx" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_EDITOR) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "fovx" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
else
- p_list->push_back( PropertyInfo( Variant::REAL, "fovy" , PROPERTY_HINT_RANGE, "1,89,0.1",PROPERTY_USAGE_EDITOR) );
+ p_list->push_back( PropertyInfo( Variant::REAL, "fovy" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
} break;
@@ -680,8 +680,6 @@ void Camera::_bind_methods() {
ObjectTypeDB::bind_method( _MD("get_projection"),&Camera::get_projection );
ObjectTypeDB::bind_method( _MD("set_visible_layers","mask"),&Camera::set_visible_layers );
ObjectTypeDB::bind_method( _MD("get_visible_layers"),&Camera::get_visible_layers );
- ObjectTypeDB::bind_method( _MD("look_at","target","up"),&Camera::look_at );
- ObjectTypeDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Camera::look_at_from_pos );
ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&Camera::set_environment);
ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&Camera::get_environment);
ObjectTypeDB::bind_method(_MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode);
@@ -752,22 +750,6 @@ Vector<Plane> Camera::get_frustum() const {
-void Camera::look_at(const Vector3& p_target, const Vector3& p_up_normal) {
-
- Transform lookat;
- lookat.origin=get_camera_transform().origin;
- lookat=lookat.looking_at(p_target,p_up_normal);
- set_global_transform(lookat);
-}
-
-void Camera::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal) {
-
- Transform lookat;
- lookat.origin=p_pos;
- lookat=lookat.looking_at(p_target,p_up_normal);
- set_global_transform(lookat);
-
-}
void Camera::set_v_offset(float p_offset) {
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 950688dfda..de03282021 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -139,8 +139,6 @@ public:
void set_keep_aspect_mode(KeepAspect p_aspect);
KeepAspect get_keep_aspect_mode() const;
- void look_at(const Vector3& p_target, const Vector3& p_up_normal);
- void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
void set_v_offset(float p_offset);
float get_v_offset() const;
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index a5b009823c..6e11855543 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -593,6 +593,97 @@ bool Spatial::_is_visible_() const {
return !is_hidden();
}
+void Spatial::rotate(const Vector3& p_normal,float p_radians) {
+
+ Transform t =get_transform();
+ t.basis.rotate(p_normal,p_radians);
+ set_transform(t);
+}
+
+void Spatial::rotate_x(float p_radians) {
+
+ Transform t =get_transform();
+ t.basis.rotate(Vector3(1,0,0),p_radians);
+ set_transform(t);
+
+}
+
+void Spatial::rotate_y(float p_radians){
+
+ Transform t =get_transform();
+ t.basis.rotate(Vector3(0,1,0),p_radians);
+ set_transform(t);
+
+}
+void Spatial::rotate_z(float p_radians){
+
+ Transform t =get_transform();
+ t.basis.rotate(Vector3(0,0,1),p_radians);
+ set_transform(t);
+
+}
+
+void Spatial::translate(const Vector3& p_offset){
+
+ Transform t =get_transform();
+ t.origin+=p_offset;
+ set_transform(t);
+
+}
+void Spatial::scale(const Vector3& p_ratio){
+
+ Transform t =get_transform();
+ t.basis.scale(p_ratio);
+ set_transform(t);
+
+}
+void Spatial::global_rotate(const Vector3& p_normal,float p_radians){
+
+ Matrix3 rotation(p_normal,p_radians);
+ Transform t = get_global_transform();
+ t.basis= rotation * t.basis;
+ set_global_transform(t);
+
+}
+void Spatial::global_translate(const Vector3& p_offset){
+ Transform t = get_global_transform();
+ t.origin+=p_offset;
+ set_global_transform(t);
+
+}
+
+void Spatial::orthonormalize() {
+
+ Transform t = get_transform();
+ t.orthonormalize();
+ set_transform(t);
+
+}
+
+void Spatial::set_identity() {
+
+ set_transform(Transform());
+
+}
+
+
+void Spatial::look_at(const Vector3& p_target, const Vector3& p_up_normal) {
+
+ Transform lookat;
+ lookat.origin=get_global_transform().origin;
+ lookat=lookat.looking_at(p_target,p_up_normal);
+ set_global_transform(lookat);
+}
+
+void Spatial::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal) {
+
+ Transform lookat;
+ lookat.origin=p_pos;
+ lookat=lookat.looking_at(p_target,p_up_normal);
+ set_global_transform(lookat);
+
+}
+
void Spatial::_bind_methods() {
@@ -633,6 +724,28 @@ void Spatial::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_);
ObjectTypeDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_);
+ void rotate(const Vector3& p_normal,float p_radians);
+ void rotate_x(float p_radians);
+ void rotate_y(float p_radians);
+ void rotate_z(float p_radians);
+ void translate(const Vector3& p_offset);
+ void scale(const Vector3& p_ratio);
+ void global_rotate(const Vector3& p_normal,float p_radians);
+ void global_translate(const Vector3& p_offset);
+
+ ObjectTypeDB::bind_method( _MD("rotate","normal","radians"),&Spatial::rotate );
+ ObjectTypeDB::bind_method( _MD("global_rotate","normal","radians"),&Spatial::global_rotate );
+ ObjectTypeDB::bind_method( _MD("rotate_x","radians"),&Spatial::rotate_x );
+ ObjectTypeDB::bind_method( _MD("rotate_y","radians"),&Spatial::rotate_y );
+ ObjectTypeDB::bind_method( _MD("rotate_z","radians"),&Spatial::rotate_z );
+ ObjectTypeDB::bind_method( _MD("translate","offset"),&Spatial::translate );
+ ObjectTypeDB::bind_method( _MD("global_translate","offset"),&Spatial::global_translate );
+ ObjectTypeDB::bind_method( _MD("orthonormalize"),&Spatial::orthonormalize );
+ ObjectTypeDB::bind_method( _MD("set_identity"),&Spatial::set_identity );
+
+ ObjectTypeDB::bind_method( _MD("look_at","target","up"),&Spatial::look_at );
+ ObjectTypeDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Spatial::look_at_from_pos );
+
BIND_CONSTANT( NOTIFICATION_TRANSFORM_CHANGED );
BIND_CONSTANT( NOTIFICATION_ENTER_WORLD );
BIND_CONSTANT( NOTIFICATION_EXIT_WORLD );
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index 49ecf5779b..f2cde8f1e6 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -167,6 +167,21 @@ public:
Transform get_relative_transform(const Node *p_parent) const;
+ void rotate(const Vector3& p_normal,float p_radians);
+ void rotate_x(float p_radians);
+ void rotate_y(float p_radians);
+ void rotate_z(float p_radians);
+ void translate(const Vector3& p_offset);
+ void scale(const Vector3& p_ratio);
+ void global_rotate(const Vector3& p_normal,float p_radians);
+ void global_translate(const Vector3& p_offset);
+
+ void look_at(const Vector3& p_target, const Vector3& p_up_normal);
+ void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
+
+ void orthonormalize();
+ void set_identity();
+
void show();
void hide();
bool is_visible() const;
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index a82c69e67f..45c7fa912c 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -310,6 +310,17 @@ int GeometryInstance::get_baked_light_texture_id() const{
return baked_light_texture_id;
}
+void GeometryInstance::set_extra_cull_margin(float p_margin) {
+
+ ERR_FAIL_COND(p_margin<0);
+ extra_cull_margin=p_margin;
+ VS::get_singleton()->instance_set_extra_visibility_margin(get_instance(),extra_cull_margin);
+}
+
+float GeometryInstance::get_extra_cull_margin() const{
+
+ return extra_cull_margin;
+}
void GeometryInstance::_bind_methods() {
@@ -328,6 +339,9 @@ void GeometryInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_baked_light_texture_id","id"), &GeometryInstance::set_baked_light_texture_id);
ObjectTypeDB::bind_method(_MD("get_baked_light_texture_id"), &GeometryInstance::get_baked_light_texture_id);
+ ObjectTypeDB::bind_method(_MD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
+ ObjectTypeDB::bind_method(_MD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
+
ObjectTypeDB::bind_method(_MD("_baked_light_changed"), &GeometryInstance::_baked_light_changed);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);
@@ -336,6 +350,7 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/receive_shadows"), _SCS("set_flag"), _SCS("get_flag"),FLAG_RECEIVE_SHADOWS);
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_begin",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_begin"), _SCS("get_draw_range_begin"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_end",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_end"), _SCS("get_draw_range_end"));
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "geometry/extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard_y"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD_FIX_Y);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/depth_scale"), _SCS("set_flag"), _SCS("get_flag"),FLAG_DEPH_SCALE);
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index e9fefe1ba0..e08acbe9a2 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -108,6 +108,7 @@ private:
void _find_baked_light();
BakedLightInstance *baked_light_instance;
int baked_light_texture_id;
+ float extra_cull_margin;
void _baked_light_changed();
void _update_visibility();
@@ -132,6 +133,9 @@ public:
void set_baked_light_texture_id(int p_id);
int get_baked_light_texture_id() const;
+ void set_extra_cull_margin(float p_margin);
+ float get_extra_cull_margin() const;
+
GeometryInstance();
};
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 0167687621..bbe15da1cc 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -279,12 +279,12 @@ void BaseButton::set_disabled(bool p_disabled) {
set_focus_mode(FOCUS_NONE);
else
set_focus_mode(FOCUS_ALL);
-};
+}
bool BaseButton::is_disabled() const {
return status.disabled;
-};
+}
void BaseButton::set_pressed(bool p_pressed) {
@@ -391,6 +391,7 @@ void BaseButton::_bind_methods() {
ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
new file mode 100644
index 0000000000..309152ba8f
--- /dev/null
+++ b/scene/gui/check_box.cpp
@@ -0,0 +1,79 @@
+/*************************************************************************/
+/* check_button.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "check_box.h"
+
+#include "servers/visual_server.h"
+#include "button_group.h"
+
+
+void CheckBox::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_DRAW) {
+
+ RID ci = get_canvas_item();
+
+ Ref<Texture> on=Control::get_icon(is_radio() ? "radio_checked" : "checked");
+ Ref<Texture> off=Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked");
+
+ Vector2 ofs;
+ ofs.x = 0;
+ ofs.y = int((get_size().height - on->get_height())/2);
+
+ if (is_pressed())
+ on->draw(ci,ofs);
+ else
+ off->draw(ci,ofs);
+
+
+ }
+}
+
+bool CheckBox::is_radio()
+{
+ Node* parent = this;
+ do {
+ parent = parent->get_parent();
+ if (dynamic_cast< ButtonGroup* >(parent))
+ break;
+ } while (parent);
+
+ return (parent != 0);
+}
+
+CheckBox::CheckBox(const String &p_text):
+ Button(p_text)
+{
+ set_toggle_mode(true);
+ set_text_align(ALIGN_LEFT);
+
+}
+
+CheckBox::~CheckBox()
+{
+}
diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h
new file mode 100644
index 0000000000..171fd55351
--- /dev/null
+++ b/scene/gui/check_box.h
@@ -0,0 +1,55 @@
+/*************************************************************************/
+/* check_box.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef CHECK_BOX_H
+#define CHECK_BOX_H
+
+
+#include "scene/gui/button.h"
+/**
+@author Mariano Suligoy <marianognu.esyrpg@gmail.com>
+*/
+class CheckBox : public Button {
+
+ OBJ_TYPE( CheckBox, Button );
+
+
+protected:
+ void _notification(int p_what);
+
+ bool is_radio();
+
+
+public:
+
+ CheckBox(const String& p_text=String());
+ ~CheckBox();
+
+};
+
+#endif
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 193649c815..d944b804a5 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -352,6 +352,7 @@ void ColorPickerButton::set_color(const Color& p_color){
picker->set_color(p_color);
+ update();
}
Color ColorPickerButton::get_color() const{
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index a8070be91d..86f442fd8c 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -940,67 +940,67 @@ void Control::_window_input_event(InputEvent p_event) {
case InputEvent::MOUSE_BUTTON: {
- window->key_event_accepted=false;
+ window->key_event_accepted=false;
- Point2 mpos =(get_canvas_transform()).affine_inverse().xform(Point2(p_event.mouse_button.x,p_event.mouse_button.y));
- if (p_event.mouse_button.pressed) {
+ Point2 mpos =(get_canvas_transform()).affine_inverse().xform(Point2(p_event.mouse_button.x,p_event.mouse_button.y));
+ if (p_event.mouse_button.pressed) {
- Size2 pos = mpos;
- if (window->mouse_focus && p_event.mouse_button.button_index!=window->mouse_focus_button) {
+ Size2 pos = mpos;
+ if (window->mouse_focus && p_event.mouse_button.button_index!=window->mouse_focus_button) {
- //do not steal mouse focus and stuff
+ //do not steal mouse focus and stuff
- } else {
+ } else {
- _window_sort_modal_stack();
- while (!window->modal_stack.empty()) {
+ _window_sort_modal_stack();
+ while (!window->modal_stack.empty()) {
- Control *top = window->modal_stack.back()->get();
- if (!top->has_point(top->get_global_transform().affine_inverse().xform(pos))) {
+ Control *top = window->modal_stack.back()->get();
+ if (!top->has_point(top->get_global_transform().affine_inverse().xform(pos))) {
- if (top->data.modal_exclusive) {
- //cancel event, sorry, modal exclusive EATS UP ALL
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
- get_tree()->set_input_as_handled();
- return; // no one gets the event if exclusive NO ONE
- }
+ if (top->data.modal_exclusive) {
+ //cancel event, sorry, modal exclusive EATS UP ALL
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
+ get_tree()->set_input_as_handled();
+ return; // no one gets the event if exclusive NO ONE
+ }
- top->notification(NOTIFICATION_MODAL_CLOSE);
- top->_modal_stack_remove();
- top->hide();
- } else {
- break;
+ top->notification(NOTIFICATION_MODAL_CLOSE);
+ top->_modal_stack_remove();
+ top->hide();
+ } else {
+ break;
+ }
}
- }
- Matrix32 parent_xform;
+ Matrix32 parent_xform;
- if (data.parent_canvas_item)
- parent_xform=data.parent_canvas_item->get_global_transform();
+ if (data.parent_canvas_item)
+ parent_xform=data.parent_canvas_item->get_global_transform();
- window->mouse_focus = _find_control_at_pos(this,pos,parent_xform,window->focus_inv_xform);
- //print_line("has mf "+itos(window->mouse_focus!=NULL));
- window->mouse_focus_button=p_event.mouse_button.button_index;
+ window->mouse_focus = _find_control_at_pos(this,pos,parent_xform,window->focus_inv_xform);
+ //print_line("has mf "+itos(window->mouse_focus!=NULL));
+ window->mouse_focus_button=p_event.mouse_button.button_index;
- if (!window->mouse_focus) {
- break;
- }
+ if (!window->mouse_focus) {
+ break;
+ }
- if (p_event.mouse_button.button_index==BUTTON_LEFT) {
- window->drag_accum=Vector2();
- window->drag_attempted=false;
- window->drag_data=Variant();
- }
+ if (p_event.mouse_button.button_index==BUTTON_LEFT) {
+ window->drag_accum=Vector2();
+ window->drag_attempted=false;
+ window->drag_data=Variant();
+ }
- }
+ }
p_event.mouse_button.global_x = pos.x;
p_event.mouse_button.global_y = pos.y;
@@ -1020,8 +1020,8 @@ void Control::_window_input_event(InputEvent p_event) {
/*if (bool(GLOBAL_DEF("debug/print_clicked_control",false))) {
- print_line(String(window->mouse_focus->get_path())+" - "+pos);
- }*/
+ print_line(String(window->mouse_focus->get_path())+" - "+pos);
+ }*/
#endif
if (window->mouse_focus->get_focus_mode()!=FOCUS_NONE && window->mouse_focus!=window->key_focus && p_event.mouse_button.button_index==BUTTON_LEFT) {
@@ -1033,10 +1033,12 @@ void Control::_window_input_event(InputEvent p_event) {
if (window->mouse_focus->can_process()) {
_window_call_input(window->mouse_focus,p_event);
}
-
+
get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
+ window->tooltip_popup->hide();
+
} else {
if (window->drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index fbcfdb69bb..47f862a58d 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -29,6 +29,8 @@
#include "file_dialog.h"
#include "scene/gui/label.h"
#include "print_string.h"
+#include "os/keyboard.h"
+#include "tools/editor/editor_settings.h"
FileDialog::GetIconFunc FileDialog::get_icon_func=NULL;
@@ -278,13 +280,20 @@ void FileDialog::update_file_list() {
List<String> dirs;
bool isdir;
+ bool ishidden;
+ bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files");
String item;
+
while ((item=dir_access->get_next(&isdir))!="") {
-
- if (!isdir)
- files.push_back(item);
- else
- dirs.push_back(item);
+
+ ishidden = dir_access->current_is_hidden();
+
+ if (show_hidden || !ishidden) {
+ if (!isdir)
+ files.push_back(item);
+ else
+ dirs.push_back(item);
+ }
}
dirs.sort_custom<NoCaseComparator>();
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index d2e1e7f0b9..892e4c9bc7 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -72,6 +72,7 @@ void Label::_notification(int p_what) {
if (clip && !autowrap)
VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
+
if (word_cache_dirty)
regenerate_word_cache();
@@ -87,7 +88,8 @@ void Label::_notification(int p_what) {
bool use_outlinde = get_constant("shadow_as_outline");
Point2 shadow_ofs(get_constant("shadow_offset_x"),get_constant("shadow_offset_y"));
-
+ VisualServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(),font.is_valid() && font->is_distance_field_hint());
+
int font_h = font->get_height();
int line_from=(int)get_val(); // + p_exposed.pos.y / font_h;
int lines_visible = size.y/font_h;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 8855627bb4..b26b55f076 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -498,7 +498,29 @@ void TextEdit::_notification(int p_what) {
for(int j=from;j<text[i].length();j++) {
CharType cc = text[i][j];
- if (cc==c)
+ //ignore any brackets inside a string
+ if (cc== '"' | cc == '\'') {
+ CharType quotation = cc;
+ do {
+ j++;
+ if (!(j<text[i].length())) {
+ break;
+ }
+ cc=text[i][j];
+ //skip over escaped quotation marks inside strings
+ if (cc=='\\') {
+ bool escaped = true;
+ while (j+1<text[i].length() && text[i][j+1]=='\\') {
+ escaped=!escaped;
+ j++;
+ }
+ if (escaped) {
+ j++;
+ continue;
+ }
+ }
+ } while (cc!= quotation);
+ } else if (cc==c)
stack++;
else if (cc==closec)
stack--;
@@ -547,7 +569,30 @@ void TextEdit::_notification(int p_what) {
for(int j=from;j>=0;j--) {
CharType cc = text[i][j];
- if (cc==c)
+ //ignore any brackets inside a string
+ if (cc== '"' | cc == '\'') {
+ CharType quotation = cc;
+ do {
+ j--;
+ if (!(j>=0)) {
+ break;
+ }
+ cc=text[i][j];
+ //skip over escaped quotation marks inside strings
+ if (cc==quotation) {
+ bool escaped = false;
+ while (j-1>=0 && text[i][j-1]=='\\') {
+ escaped=!escaped;
+ j--;
+ }
+ if (escaped) {
+ j--;
+ cc='\\';
+ continue;
+ }
+ }
+ } while (cc!= quotation);
+ } else if (cc==c)
stack++;
else if (cc==closec)
stack--;
@@ -1345,7 +1390,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
return;
}
- if (k.scancode==KEY_HOME) {
+ if (k.scancode==KEY_HOME && completion_index>0) {
completion_index=0;
completion_current=completion_options[completion_index];
@@ -1354,7 +1399,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
return;
}
- if (k.scancode==KEY_END) {
+ if (k.scancode==KEY_END && completion_index<completion_options.size()-1) {
completion_index=completion_options.size()-1;
completion_current=completion_options[completion_index];
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 02e009866f..ee400ae6d5 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -30,7 +30,7 @@
#include "os/os.h"
#include "scene/3d/spatial.h"
#include "os/input.h"
-
+#include "servers/physics_2d_server.h"
//#include "scene/3d/camera.h"
#include "servers/spatial_sound_server.h"
@@ -40,7 +40,7 @@
#include "scene/3d/spatial_indexer.h"
#include "scene/3d/collision_object.h"
-
+#include "scene/2d/collision_object_2d.h"
int RenderTargetTexture::get_width() const {
@@ -104,8 +104,10 @@ void Viewport::_update_stretch_transform() {
stretch_transform.scale(scale);
stretch_transform.elements[2]=size_override_margin*scale;
+
} else {
+
stretch_transform=Matrix32();
}
@@ -355,11 +357,12 @@ void Viewport::_notification(int p_what) {
case NOTIFICATION_FIXED_PROCESS: {
if (physics_object_picking) {
-#ifndef _3D_DISABLED
+
Vector2 last_pos(1e20,1e20);
CollisionObject *last_object;
ObjectID last_id=0;
PhysicsDirectSpaceState::RayResult result;
+ Physics2DDirectSpaceState *ss2d=Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
bool motion_tested=false;
@@ -392,6 +395,60 @@ void Viewport::_notification(int p_what) {
}
+ if (ss2d) {
+ //send to 2D
+
+
+ uint64_t frame = get_tree()->get_frame();
+
+ Vector2 point = get_canvas_transform().affine_inverse().xform(pos);
+ Physics2DDirectSpaceState::ShapeResult res[64];
+ int rc = ss2d->intersect_point(point,res,64,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF);
+ for(int i=0;i<rc;i++) {
+
+ if (res[i].collider) {
+ CollisionObject2D *co=res[i].collider->cast_to<CollisionObject2D>();
+ if (co) {
+
+ Map<ObjectID,uint64_t>::Element *E=physics_2d_mouseover.find(res[i].collider_id);
+ if (!E) {
+ E=physics_2d_mouseover.insert(res[i].collider_id,frame);
+ co->_mouse_enter();
+ } else {
+ E->get()=frame;
+ }
+
+ co->_input_event(this,ev,res[i].shape);
+ }
+ }
+ }
+
+ List<Map<ObjectID,uint64_t>::Element*> to_erase;
+
+ for (Map<ObjectID,uint64_t>::Element*E=physics_2d_mouseover.front();E;E=E->next()) {
+ if (E->get()!=frame) {
+ Object *o=ObjectDB::get_instance(E->key());
+ if (o) {
+
+ CollisionObject2D *co=o->cast_to<CollisionObject2D>();
+ if (co) {
+ co->_mouse_exit();
+ }
+ }
+ to_erase.push_back(E);
+ }
+ }
+
+ while(to_erase.size()) {
+ physics_2d_mouseover.erase(to_erase.front()->get());
+ to_erase.pop_front();
+ }
+
+ }
+
+
+
+#ifndef _3D_DISABLED
bool captured=false;
if (physics_object_capture!=0) {
@@ -499,9 +556,9 @@ void Viewport::_notification(int p_what) {
_test_new_mouseover(new_collider);
}
-
- }
#endif
+ }
+
}
} break;
@@ -1021,8 +1078,9 @@ Matrix32 Viewport::_get_input_pre_xform() const {
ERR_FAIL_COND_V(to_screen_rect.size.x==0,pre_xf);
ERR_FAIL_COND_V(to_screen_rect.size.y==0,pre_xf);
- pre_xf.scale(rect.size/to_screen_rect.size);
+
pre_xf.elements[2]=-to_screen_rect.pos;
+ pre_xf.scale(rect.size/to_screen_rect.size);
} else {
pre_xf.elements[2]=-rect.pos;
@@ -1086,6 +1144,7 @@ void Viewport::_make_input_local(InputEvent& ev) {
} break;
}
+
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index d2a22401bd..14f4f68217 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -124,6 +124,7 @@ friend class RenderTargetTexture;
ObjectID physics_object_over;
Vector2 physics_last_mousepos;
void _test_new_mouseover(ObjectID new_collider);
+ Map<ObjectID,uint64_t> physics_2d_mouseover;
void _update_rect();
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index ff525203bf..afadbf0170 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -53,6 +53,7 @@
#include "scene/gui/color_picker.h"
#include "scene/gui/texture_frame.h"
#include "scene/gui/menu_button.h"
+#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/panel_container.h"
@@ -76,15 +77,18 @@
#include "scene/gui/reference_frame.h"
#include "scene/gui/graph_node.h"
#include "scene/gui/graph_edit.h"
+#include "scene/gui/tool_button.h"
#include "scene/resources/video_stream.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/path_2d.h"
#include "scene/2d/light_2d.h"
+#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/canvas_item.h"
#include "scene/2d/sprite.h"
#include "scene/2d/animated_sprite.h"
#include "scene/2d/polygon_2d.h"
+#include "scene/2d/back_buffer_copy.h"
#include "scene/2d/visibility_notifier_2d.h"
@@ -287,7 +291,9 @@ void register_scene_types() {
ObjectTypeDB::register_type<Popup>();
ObjectTypeDB::register_type<PopupPanel>();
ObjectTypeDB::register_type<MenuButton>();
+ ObjectTypeDB::register_type<CheckBox>();
ObjectTypeDB::register_type<CheckButton>();
+ ObjectTypeDB::register_type<ToolButton>();
ObjectTypeDB::register_type<Panel>();
ObjectTypeDB::register_type<Range>();
@@ -454,6 +460,7 @@ void register_scene_types() {
//ObjectTypeDB::set_type_enabled("BodyVolumeCylinder",false);
//ObjectTypeDB::set_type_enabled("BodyVolumeConvexPolygon",false);
+ ObjectTypeDB::register_type<CanvasItemMaterial>();
ObjectTypeDB::register_virtual_type<CanvasItem>();
ObjectTypeDB::register_type<Node2D>();
ObjectTypeDB::register_type<Particles2D>();
@@ -476,7 +483,10 @@ void register_scene_types() {
ObjectTypeDB::register_type<VisibilityEnabler2D>();
ObjectTypeDB::register_type<Polygon2D>();
ObjectTypeDB::register_type<Light2D>();
+ ObjectTypeDB::register_type<LightOccluder2D>();
+ ObjectTypeDB::register_type<OccluderPolygon2D>();
ObjectTypeDB::register_type<YSort>();
+ ObjectTypeDB::register_type<BackBufferCopy>();
ObjectTypeDB::set_type_enabled("CollisionShape2D",false);
ObjectTypeDB::set_type_enabled("CollisionPolygon2D",false);
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 4d1e9896db..7d5981522e 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -300,6 +300,40 @@ void make_default_theme() {
t->set_constant("hseparation","MenuButton", 0 );
+ // CheckBox
+
+ Ref<StyleBox> cbx_empty = memnew( StyleBoxEmpty );
+ cbx_empty->set_default_margin(MARGIN_LEFT,22);
+ cbx_empty->set_default_margin(MARGIN_RIGHT,4);
+ cbx_empty->set_default_margin(MARGIN_TOP,4);
+ cbx_empty->set_default_margin(MARGIN_BOTTOM,5);
+ Ref<StyleBox> cbx_focus = focus;
+ cbx_focus->set_default_margin(MARGIN_LEFT,4);
+ cbx_focus->set_default_margin(MARGIN_RIGHT,22);
+ cbx_focus->set_default_margin(MARGIN_TOP,4);
+ cbx_focus->set_default_margin(MARGIN_BOTTOM,5);
+
+ t->set_stylebox("normal","CheckBox", cbx_empty );
+ t->set_stylebox("pressed","CheckBox", cbx_empty );
+ t->set_stylebox("disabled","CheckBox", cbx_empty );
+ t->set_stylebox("hover","CheckBox", cbx_empty );
+ t->set_stylebox("focus","CheckBox", cbx_focus );
+
+ t->set_icon("checked", "CheckBox", make_icon(checked_png));
+ t->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
+ t->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
+ t->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
+
+ t->set_font("font","CheckBox", default_font );
+
+ t->set_color("font_color","CheckBox", control_font_color );
+ t->set_color("font_color_pressed","CheckBox", control_font_color_pressed );
+ t->set_color("font_color_hover","CheckBox", control_font_color_hover );
+ t->set_color("font_color_disabled","CheckBox", control_font_color_disabled );
+
+ t->set_constant("hseparation","CheckBox",4);
+ t->set_constant("check_vadjust","CheckBox",0);
+
// CheckButton
@@ -308,7 +342,7 @@ void make_default_theme() {
cb_empty->set_default_margin(MARGIN_LEFT,6);
cb_empty->set_default_margin(MARGIN_RIGHT,70);
cb_empty->set_default_margin(MARGIN_TOP,4);
- cb_empty->set_default_margin(MARGIN_BOTTOM,4);
+ cb_empty->set_default_margin(MARGIN_BOTTOM,4);
t->set_stylebox("normal","CheckButton", cb_empty );
t->set_stylebox("pressed","CheckButton", cb_empty );
@@ -540,7 +574,7 @@ void make_default_theme() {
// Tree
Ref<StyleBoxTexture> tree_selected = make_stylebox( selection_png,4,4,4,4,8,0,8,0);
- Ref<StyleBoxTexture> tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,0,8,0);
+ Ref<StyleBoxTexture> tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,0,8,0);
t->set_stylebox("bg","Tree", make_stylebox( tree_bg_png,4,4,4,5) );
t->set_stylebox("bg_focus","Tree", focus );
diff --git a/scene/resources/default_theme/radio_checked.png b/scene/resources/default_theme/radio_checked.png
new file mode 100644
index 0000000000..ada8dde3c1
--- /dev/null
+++ b/scene/resources/default_theme/radio_checked.png
Binary files differ
diff --git a/scene/resources/default_theme/radio_unchecked.png b/scene/resources/default_theme/radio_unchecked.png
new file mode 100644
index 0000000000..018af99afd
--- /dev/null
+++ b/scene/resources/default_theme/radio_unchecked.png
Binary files differ
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index e9a6d3dad6..78e210239d 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -264,6 +264,16 @@ static const unsigned char progress_fill_png[]={
};
+static const unsigned char radio_checked_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x3,0x1,0x4,0x19,0x36,0x83,0x13,0x8d,0xb2,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x1,0x9d,0x49,0x44,0x41,0x54,0x38,0xcb,0xad,0x93,0x31,0x6b,0xdb,0x50,0x14,0x85,0x3f,0x59,0x8a,0x21,0xbb,0x17,0xd1,0x37,0xa4,0xa4,0xb5,0x10,0xb5,0x3,0xfa,0x7,0x5d,0x3a,0x74,0xf2,0x56,0x39,0x64,0x4d,0x97,0x42,0x9b,0xce,0x6d,0x7e,0x44,0xe3,0x8e,0xf5,0x60,0x4,0xc5,0x22,0x9b,0x27,0x63,0xe8,0xea,0xc5,0x43,0x4d,0x48,0x40,0x7a,0xe9,0xd0,0xe0,0xd4,0x68,0x32,0x18,0x3c,0x8,0x64,0xc3,0xed,0x50,0x59,0x34,0x71,0xa7,0x3a,0x7,0xde,0x72,0xef,0x79,0x87,0x7b,0xde,0x3d,0xf,0xb6,0x84,0x71,0xbf,0xe0,0x38,0xce,0x23,0xe0,0x2d,0xf0,0x12,0xa8,0xe6,0xe5,0x6b,0xa0,0xf,0x7c,0xd6,0x5a,0x4f,0xff,0x29,0x60,0x99,0x16,0xfb,0x4f,0xf6,0x8f,0x81,0x56,0xb3,0x79,0xb4,0x7b,0x78,0xf8,0xa,0xc3,0xf8,0xd3,0x16,0x11,0xba,0xdd,0x73,0xc2,0xf0,0x6b,0xa,0xbc,0x9b,0x4c,0x26,0xed,0x34,0x4d,0xef,0xa,0x38,0x8e,0x73,0xbc,0xb7,0xf7,0xf8,0xcb,0xd9,0xd9,0xa7,0xe2,0xe2,0x7d,0x88,0x8,0x27,0x27,0xef,0xb9,0xb9,0xf9,0xf9,0x5a,0x6b,0xdd,0x2e,0x4,0xf2,0xb1,0x7f,0xf4,0x7a,0xbd,0x5d,0xc3,0x30,0xc8,0xb2,0x8c,0xf1,0x78,0x4c,0x14,0x45,0x0,0xb8,0xae,0x8b,0xe7,0x79,0x94,0xcb,0x65,0x44,0x84,0x46,0xa3,0x91,0x2,0x4f,0xb5,0xd6,0x53,0x13,0xa0,0x52,0xa9,0x7c,0x6c,0x36,0x8f,0x9e,0x1f,0x1c,0xd4,0xc8,0xb2,0x8c,0x4e,0xa7,0x43,0xab,0xd5,0x62,0x30,0x18,0x30,0x1c,0xe,0x19,0x8d,0x46,0xac,0x56,0x2b,0xea,0xf5,0x3a,0x96,0x65,0x21,0x52,0xda,0xb9,0xba,0xba,0x5c,0xce,0x66,0xb3,0x6f,0xeb,0xf1,0x2f,0xe2,0x38,0x16,0xad,0xb5,0x4,0x41,0x20,0x4a,0x29,0x1,0xee,0x1c,0xa5,0x94,0x4,0x41,0x20,0x5a,0x6b,0x89,0xe3,0x58,0x1c,0xc7,0xb9,0x0,0x28,0xe5,0xf6,0xaa,0x6b,0xdf,0x51,0x14,0x91,0x24,0xc9,0x86,0xff,0x24,0x49,0xa,0x4b,0x39,0xb7,0xfa,0xb7,0xc0,0x7f,0x63,0x2d,0x70,0x2d,0x22,0xc5,0x83,0xd9,0xb6,0xbd,0x41,0xb4,0x6d,0x1b,0xd7,0x75,0x8b,0x6d,0xe4,0xd9,0x28,0x4,0xfa,0xdd,0xee,0x39,0x0,0x9e,0xe7,0xe1,0xfb,0x3e,0x4a,0x29,0x4c,0xd3,0xc4,0x34,0x4d,0x94,0x52,0xf8,0xbe,0x8f,0xe7,0x79,0x0,0xe4,0xdc,0xfe,0x83,0xac,0x71,0xeb,0x20,0x99,0xeb,0xe6,0x62,0xb1,0xf8,0x6e,0x18,0x4c,0xc3,0x30,0x7c,0x21,0x52,0xda,0xa9,0xd5,0x9e,0x6d,0x44,0xf9,0xf4,0xf4,0x43,0x3a,0x9f,0xcf,0xdf,0xdc,0xde,0xfe,0x6a,0x2f,0x97,0xcb,0x87,0xf9,0x4c,0x5b,0xe3,0x37,0x57,0xdf,0xd7,0x8,0xe6,0x62,0x7d,0xab,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
+static const unsigned char radio_unchecked_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x3,0x1,0x4,0x1b,0x6,0x97,0xfc,0xdf,0x9c,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x1,0x9,0x49,0x44,0x41,0x54,0x38,0xcb,0xad,0x93,0xbd,0x72,0x82,0x40,0x14,0x85,0xf,0x68,0xa,0x9e,0x21,0x8d,0x8e,0x9,0xdb,0xc4,0xc7,0x48,0x41,0x43,0x2b,0xa3,0xad,0x69,0x32,0xc3,0xda,0xc7,0xa7,0x8,0x94,0xa1,0xd,0x68,0x4b,0xc3,0x5b,0xd8,0x5f,0x2d,0xe2,0x60,0xe8,0x99,0xa1,0xd8,0x82,0xc2,0x34,0x17,0x67,0x35,0x19,0x43,0x34,0xa7,0xbc,0x7b,0xee,0x37,0xf7,0x6f,0x81,0x2b,0x65,0x9c,0x6,0x84,0x10,0xb7,0x0,0x7c,0x0,0xe,0x0,0x9b,0xc3,0x6b,0x0,0x19,0x80,0x90,0x88,0x8a,0x1f,0x1,0xdd,0x4e,0x17,0x83,0xbb,0xc1,0x14,0x40,0xe0,0x79,0x13,0x6b,0x3c,0x1e,0x1d,0x81,0xe3,0x78,0x89,0xc5,0xe2,0x5d,0x1,0x90,0x79,0x9e,0x47,0x4a,0xa9,0x63,0x80,0x10,0x62,0xda,0xeb,0xf5,0xdf,0x82,0xe0,0xf5,0x6c,0xc9,0x52,0xce,0xb0,0xdd,0x7e,0x3c,0x11,0x51,0x74,0x0,0x70,0xd9,0x9b,0x34,0x4d,0xad,0x36,0x7d,0xbb,0xae,0xab,0x0,0xdc,0x13,0x51,0x61,0x72,0xcc,0xf7,0xbc,0x89,0xd5,0x76,0x70,0xec,0xf5,0x1,0xa0,0x1,0x38,0xa7,0x3d,0x9f,0x13,0x7b,0x1d,0x1d,0x60,0x5f,0xb0,0x41,0x5b,0x7,0x5c,0x2c,0x53,0xdb,0xf3,0x5f,0xb5,0xd6,0x1,0x59,0x1c,0x2f,0x5b,0x67,0xb2,0x37,0xd3,0x1,0x21,0x1f,0x49,0x2b,0xb1,0x37,0x3c,0x0,0xf8,0x3c,0xa5,0x94,0xb3,0x5f,0x93,0xd9,0x23,0x9b,0x93,0xee,0x34,0xf,0x55,0x55,0xad,0xc,0x3,0x45,0x92,0x24,0x8f,0xfb,0xbd,0x79,0x33,0x1c,0x3e,0x7c,0x2b,0x7b,0x3e,0x7f,0x51,0x65,0x59,0x3e,0xef,0x76,0x9f,0x51,0x5d,0xd7,0xff,0xf3,0x99,0xae,0xd6,0x17,0xf,0x97,0x66,0x8b,0x3d,0xf1,0x64,0x47,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
static const unsigned char reference_border_png[]={
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x1,0x73,0x52,0x47,0x42,0x0,0xae,0xce,0x1c,0xe9,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdb,0x7,0x9,0x11,0x2b,0x1a,0xed,0xf3,0x18,0x82,0x0,0x0,0x0,0x5b,0x49,0x44,0x41,0x54,0x38,0xcb,0x63,0xfc,0xbf,0x7d,0xfb,0x7f,0x6,0x6,0x6,0x6,0x86,0xae,0x2e,0x6,0x92,0x40,0x59,0x19,0x84,0x86,0x1b,0x40,0x6,0xf8,0xbf,0x7d,0xfb,0x7f,0xc6,0xff,0x8e,0x8e,0xff,0x19,0xf7,0xef,0x67,0xfc,0x7f,0xf1,0x22,0x49,0x9a,0x19,0xf5,0xf5,0x19,0xfe,0x3b,0x3a,0xfe,0x67,0x41,0x17,0x24,0xca,0x66,0x24,0xcb,0x98,0x18,0x28,0x4,0xa3,0x6,0x8c,0x1a,0xc0,0xc0,0xc0,0xc0,0xc0,0x82,0x2b,0x85,0x91,0x94,0x21,0x28,0xcb,0x4c,0x14,0x66,0x67,0x0,0x0,0x2b,0x27,0xc7,0x5e,0xa8,0x15,0xe4,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 3c4bc3ac75..1e3b9772ee 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -108,13 +108,14 @@ void Environment::_bind_methods() {
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fxaa/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FXAA);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"background/mode",PROPERTY_HINT_ENUM,"Keep,Default Color,Color,Texture,Cubemap,Texture RGBE,Cubemap RGBE"),_SCS("set_background"),_SCS("get_background"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"background/mode",PROPERTY_HINT_ENUM,"Keep,Default Color,Color,Texture,Cubemap,Canvas"),_SCS("set_background"),_SCS("get_background"));
ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"background/color"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_COLOR);
ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_TEXTURE);
ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/cubemap",PROPERTY_HINT_RESOURCE_TYPE,"CubeMap"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CUBEMAP);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/energy",PROPERTY_HINT_RANGE,"0,128,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_ENERGY);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/scale",PROPERTY_HINT_RANGE,"0.001,16,0.001"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_SCALE);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/glow",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_GLOW);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"background/canvas_max_layer"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CANVAS_MAX_LAYER);
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"glow/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_GLOW);
ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_PASSES);
@@ -182,10 +183,10 @@ void Environment::_bind_methods() {
BIND_CONSTANT( BG_COLOR );
BIND_CONSTANT( BG_TEXTURE );
BIND_CONSTANT( BG_CUBEMAP );
- BIND_CONSTANT( BG_TEXTURE_RGBE );
- BIND_CONSTANT( BG_CUBEMAP_RGBE );
+ BIND_CONSTANT( BG_CANVAS );
BIND_CONSTANT( BG_MAX );
+ BIND_CONSTANT( BG_PARAM_CANVAS_MAX_LAYER );
BIND_CONSTANT( BG_PARAM_COLOR );
BIND_CONSTANT( BG_PARAM_TEXTURE );
BIND_CONSTANT( BG_PARAM_CUBEMAP );
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index a9e2f422b9..d672a898d5 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -44,14 +44,14 @@ public:
BG_COLOR=VS::ENV_BG_COLOR,
BG_TEXTURE=VS::ENV_BG_TEXTURE,
BG_CUBEMAP=VS::ENV_BG_CUBEMAP,
- BG_TEXTURE_RGBE=VS::ENV_BG_TEXTURE_RGBE,
- BG_CUBEMAP_RGBE=VS::ENV_BG_CUBEMAP_RGBE,
+ BG_CANVAS=VS::ENV_BG_CANVAS,
BG_MAX=VS::ENV_BG_MAX
};
enum BGParam {
- BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR,
+ BG_PARAM_CANVAS_MAX_LAYER=VS::ENV_BG_PARAM_CANVAS_MAX_LAYER,
+ BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR,
BG_PARAM_TEXTURE=VS::ENV_BG_PARAM_TEXTURE,
BG_PARAM_CUBEMAP=VS::ENV_BG_PARAM_CUBEMAP,
BG_PARAM_ENERGY=VS::ENV_BG_PARAM_ENERGY,
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 49ee3ee017..79316f0019 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -398,6 +398,17 @@ int Font::get_kerning_pair(CharType p_A,CharType p_B) const {
return 0;
}
+void Font::set_distance_field_hint(bool p_distance_field) {
+
+ distance_field_hint=p_distance_field;
+ emit_changed();
+}
+
+bool Font::is_distance_field_hint() const{
+
+ return distance_field_hint;
+}
+
void Font::clear() {
@@ -406,6 +417,7 @@ void Font::clear() {
char_map.clear();
textures.clear();
kerning_map.clear();
+ distance_field_hint=false;
}
Size2 Font::get_string_size(const String& p_string) const {
@@ -511,9 +523,16 @@ void Font::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_texture","texture:Texture"),&Font::add_texture);
ObjectTypeDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&Font::add_char,DEFVAL(Point2()),DEFVAL(-1));
+
+ ObjectTypeDB::bind_method(_MD("get_texture_count"),&Font::get_texture_count);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture","idx"),&Font::get_texture);
+
ObjectTypeDB::bind_method(_MD("get_char_size","char","next"),&Font::get_char_size,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
+ ObjectTypeDB::bind_method(_MD("set_distance_field_hint","enable"),&Font::set_distance_field_hint);
+ ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
+
ObjectTypeDB::bind_method(_MD("clear"),&Font::clear);
ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
@@ -535,12 +554,14 @@ void Font::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") );
}
Font::Font() {
clear();
+
}
diff --git a/scene/resources/font.h b/scene/resources/font.h
index a64ec1ef7a..498bc6863a 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -75,6 +75,7 @@ private:
float height;
float ascent;
+ bool distance_field_hint;
void _set_chars(const DVector<int>& p_chars);
DVector<int> _get_chars() const;
@@ -116,6 +117,9 @@ public:
Size2 get_string_size(const String& p_string) const;
void clear();
+
+ void set_distance_field_hint(bool p_distance_field);
+ bool is_distance_field_hint() const;
void draw(RID p_canvas_item, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1) const;
void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 2c1502288b..8d3cbadd06 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -321,6 +321,13 @@ void ImageTexture::premultiply_alpha() {
}
}
+void ImageTexture::normal_to_xy() {
+
+ Image img = get_data();
+ img.normalmap_to_xy();
+ create_from_image(img,flags);
+}
+
bool ImageTexture::has_alpha() const {
return ( format==Image::FORMAT_GRAYSCALE_ALPHA || format==Image::FORMAT_INDEXED_ALPHA || format==Image::FORMAT_RGBA );
@@ -405,9 +412,11 @@ void ImageTexture::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"),&ImageTexture::get_lossy_storage_quality);
ObjectTypeDB::bind_method(_MD("fix_alpha_edges"),&ImageTexture::fix_alpha_edges);
ObjectTypeDB::bind_method(_MD("premultiply_alpha"),&ImageTexture::premultiply_alpha);
+ ObjectTypeDB::bind_method(_MD("normal_to_xy"),&ImageTexture::normal_to_xy);
ObjectTypeDB::bind_method(_MD("set_size_override","size"),&ImageTexture::set_size_override);
ObjectTypeDB::set_method_flags(get_type_static(),_SCS("fix_alpha_edges"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
ObjectTypeDB::set_method_flags(get_type_static(),_SCS("premultiply_alpha"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ObjectTypeDB::set_method_flags(get_type_static(),_SCS("normal_to_xy"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
ObjectTypeDB::bind_method(_MD("_reload_hook","rid"),&ImageTexture::_reload_hook);
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index c1122b005d..e853a4b05f 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -146,6 +146,8 @@ public:
void fix_alpha_edges();
void premultiply_alpha();
+ void normal_to_xy();
+
void set_size_override(const Size2& p_size);
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 208ba5bb66..338804e0e1 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -46,6 +46,8 @@ bool TileSet::_set(const StringName& p_name, const Variant& p_value) {
tile_set_texture(id,p_value);
else if (what=="tex_offset")
tile_set_texture_offset(id,p_value);
+ else if (what=="material")
+ tile_set_material(id,p_value);
else if (what=="shape_offset")
tile_set_shape_offset(id,p_value);
else if (what=="region")
@@ -54,6 +56,14 @@ bool TileSet::_set(const StringName& p_name, const Variant& p_value) {
tile_set_shape(id,p_value);
else if (what=="shapes")
_tile_set_shapes(id,p_value);
+ else if (what=="occluder")
+ tile_set_light_occluder(id,p_value);
+ else if (what=="occluder_offset")
+ tile_set_occluder_offset(id,p_value);
+ else if (what=="navigation")
+ tile_set_navigation_polygon(id,p_value);
+ else if (what=="navigation_offset")
+ tile_set_navigation_polygon_offset(id,p_value);
else
return false;
@@ -79,6 +89,8 @@ bool TileSet::_get(const StringName& p_name,Variant &r_ret) const{
r_ret=tile_get_texture(id);
else if (what=="tex_offset")
r_ret=tile_get_texture_offset(id);
+ else if (what=="material")
+ r_ret=tile_get_material(id);
else if (what=="shape_offset")
r_ret=tile_get_shape_offset(id);
else if (what=="region")
@@ -87,6 +99,14 @@ bool TileSet::_get(const StringName& p_name,Variant &r_ret) const{
r_ret=tile_get_shape(id);
else if (what=="shapes")
r_ret=_tile_get_shapes(id);
+ else if (what=="occluder")
+ r_ret=tile_get_light_occluder(id);
+ else if (what=="occluder_offset")
+ r_ret=tile_get_occluder_offset(id);
+ else if (what=="navigation")
+ r_ret=tile_get_navigation_polygon(id);
+ else if (what=="navigation_offset")
+ r_ret=tile_get_navigation_polygon_offset(id);
else
return false;
@@ -103,8 +123,13 @@ void TileSet::_get_property_list( List<PropertyInfo> *p_list) const{
p_list->push_back(PropertyInfo(Variant::STRING,pre+"name"));
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"));
p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"tex_offset"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"shape_offset"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"material",PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemMaterial"));
p_list->push_back(PropertyInfo(Variant::RECT2,pre+"region"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"occluder_offset"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"navigation_offset"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"navigation",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"shape_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D",PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::ARRAY,pre+"shapes",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
}
@@ -134,6 +159,22 @@ Ref<Texture> TileSet::tile_get_texture(int p_id) const {
}
+
+void TileSet::tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].material=p_material;
+ emit_changed();
+
+}
+
+Ref<CanvasItemMaterial> TileSet::tile_get_material(int p_id) const{
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<CanvasItemMaterial>());
+ return tile_map[p_id].material;
+}
+
+
void TileSet::tile_set_texture_offset(int p_id,const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
@@ -210,6 +251,58 @@ Ref<Shape2D> TileSet::tile_get_shape(int p_id) const {
}
+void TileSet::tile_set_light_occluder(int p_id,const Ref<OccluderPolygon2D> &p_light_occluder) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].occluder=p_light_occluder;
+
+}
+
+Ref<OccluderPolygon2D> TileSet::tile_get_light_occluder(int p_id) const{
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<OccluderPolygon2D>());
+ return tile_map[p_id].occluder;
+
+}
+
+void TileSet::tile_set_navigation_polygon_offset(int p_id,const Vector2& p_offset) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].navigation_polygon_offset=p_offset;
+
+}
+
+Vector2 TileSet::tile_get_navigation_polygon_offset(int p_id) const{
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
+ return tile_map[p_id].navigation_polygon_offset;
+}
+
+void TileSet::tile_set_navigation_polygon(int p_id,const Ref<NavigationPolygon> &p_navigation_polygon) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].navigation_polygon=p_navigation_polygon;
+
+}
+
+Ref<NavigationPolygon> TileSet::tile_get_navigation_polygon(int p_id) const {
+
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<NavigationPolygon>());
+ return tile_map[p_id].navigation_polygon;
+
+}
+
+void TileSet::tile_set_occluder_offset(int p_id,const Vector2& p_offset) {
+
+ ERR_FAIL_COND(!tile_map.has(p_id));
+ tile_map[p_id].occluder_offset=p_offset;
+
+}
+
+Vector2 TileSet::tile_get_occluder_offset(int p_id) const{
+ ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
+ return tile_map[p_id].occluder_offset;
+}
+
void TileSet::tile_set_shapes(int p_id,const Vector<Ref<Shape2D> > &p_shapes) {
ERR_FAIL_COND(!tile_map.has(p_id));
@@ -319,6 +412,8 @@ void TileSet::_bind_methods() {
ObjectTypeDB::bind_method(_MD("tile_get_name","id"),&TileSet::tile_get_name);
ObjectTypeDB::bind_method(_MD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture);
ObjectTypeDB::bind_method(_MD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture);
+ ObjectTypeDB::bind_method(_MD("tile_set_material","id","material:CanvasItemMaterial"),&TileSet::tile_set_material);
+ ObjectTypeDB::bind_method(_MD("tile_get_material:CanvasItemMaterial","id"),&TileSet::tile_get_material);
ObjectTypeDB::bind_method(_MD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset);
ObjectTypeDB::bind_method(_MD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset);
ObjectTypeDB::bind_method(_MD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset);
@@ -329,6 +424,15 @@ void TileSet::_bind_methods() {
ObjectTypeDB::bind_method(_MD("tile_get_shape:Shape2D","id"),&TileSet::tile_get_shape);
ObjectTypeDB::bind_method(_MD("tile_set_shapes","id","shapes"),&TileSet::_tile_set_shapes);
ObjectTypeDB::bind_method(_MD("tile_get_shapes","id"),&TileSet::_tile_get_shapes);
+ ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon","id","navigation_polygon:NavigationPolygon"),&TileSet::tile_set_navigation_polygon);
+ ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon:NavigationPolygon","id"),&TileSet::tile_get_navigation_polygon);
+ ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon_offset","id","navigation_polygon_offset"),&TileSet::tile_set_navigation_polygon_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon_offset","id"),&TileSet::tile_get_navigation_polygon_offset);
+ ObjectTypeDB::bind_method(_MD("tile_set_light_occluder","id","light_occluder:OccluderPolygon2D"),&TileSet::tile_set_light_occluder);
+ ObjectTypeDB::bind_method(_MD("tile_get_light_occluder:OccluderPolygon2D","id"),&TileSet::tile_get_light_occluder);
+ ObjectTypeDB::bind_method(_MD("tile_set_occluder_offset","id","occluder_offset"),&TileSet::tile_set_occluder_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_occluder_offset","id"),&TileSet::tile_get_occluder_offset);
+
ObjectTypeDB::bind_method(_MD("remove_tile","id"),&TileSet::remove_tile);
ObjectTypeDB::bind_method(_MD("clear"),&TileSet::clear);
ObjectTypeDB::bind_method(_MD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id);
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index ddbb1b59a6..0234755a53 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -32,6 +32,8 @@
#include "resource.h"
#include "scene/resources/shape_2d.h"
#include "scene/resources/texture.h"
+#include "scene/2d/light_occluder_2d.h"
+#include "scene/2d/navigation_polygon.h"
class TileSet : public Resource {
@@ -45,6 +47,11 @@ class TileSet : public Resource {
Vector2 shape_offset;
Rect2i region;
Vector<Ref<Shape2D> > shapes;
+ Vector2 occluder_offset;
+ Ref<OccluderPolygon2D> occluder;
+ Vector2 navigation_polygon_offset;
+ Ref<NavigationPolygon> navigation_polygon;
+ Ref<CanvasItemMaterial> material;
};
Map<int,Data> tile_map;
@@ -84,6 +91,21 @@ public:
void tile_set_shape(int p_id,const Ref<Shape2D> &p_shape);
Ref<Shape2D> tile_get_shape(int p_id) const;
+ void tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material);
+ Ref<CanvasItemMaterial> tile_get_material(int p_id) const;
+
+ void tile_set_occluder_offset(int p_id,const Vector2& p_offset);
+ Vector2 tile_get_occluder_offset(int p_id) const;
+
+ void tile_set_light_occluder(int p_id,const Ref<OccluderPolygon2D> &p_light_occluder);
+ Ref<OccluderPolygon2D> tile_get_light_occluder(int p_id) const;
+
+ void tile_set_navigation_polygon_offset(int p_id,const Vector2& p_offset);
+ Vector2 tile_get_navigation_polygon_offset(int p_id) const;
+
+ void tile_set_navigation_polygon(int p_id,const Ref<NavigationPolygon> &p_navigation_polygon);
+ Ref<NavigationPolygon> tile_get_navigation_polygon(int p_id) const;
+
void tile_set_shapes(int p_id,const Vector<Ref<Shape2D> > &p_shapes);
Vector<Ref<Shape2D> > tile_get_shapes(int p_id) const;
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index 880a3a32e3..30cf58bdd8 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -307,6 +307,11 @@ Ref<Environment> World::get_environment() const {
}
+PhysicsDirectSpaceState *World::get_direct_space_state() {
+
+ return PhysicsServer::get_singleton()->space_get_direct_state(space);
+}
+
void World::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_space"),&World::get_space);
@@ -314,6 +319,7 @@ void World::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_sound_space"),&World::get_sound_space);
ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&World::set_environment);
ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&World::get_environment);
+ ObjectTypeDB::bind_method(_MD("get_direct_space_state:PhysicsDirectSpaceState"),&World::get_direct_space_state);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),_SCS("set_environment"),_SCS("get_environment"));
}
diff --git a/scene/resources/world.h b/scene/resources/world.h
index 60b3b99ab0..b10cadd6e0 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -75,6 +75,8 @@ public:
void set_environment(const Ref<Environment>& p_environment);
Ref<Environment> get_environment() const;
+ PhysicsDirectSpaceState *get_direct_space_state();
+
World();
~World();
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 0dd6a3d5e7..43a7af4bfd 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -352,8 +352,17 @@ void World2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_canvas"),&World2D::get_canvas);
ObjectTypeDB::bind_method(_MD("get_space"),&World2D::get_space);
ObjectTypeDB::bind_method(_MD("get_sound_space"),&World2D::get_sound_space);
+
+ ObjectTypeDB::bind_method(_MD("get_direct_space_state:Physics2DDirectSpaceState"),&World2D::get_direct_space_state);
+
+}
+
+Physics2DDirectSpaceState *World2D::get_direct_space_state() {
+
+ return Physics2DServer::get_singleton()->space_get_direct_state(space);
}
+
World2D::World2D() {
canvas = VisualServer::get_singleton()->canvas_create();
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index 3feb23495d..865ec28fe9 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -30,7 +30,7 @@
#define WORLD_2D_H
#include "resource.h"
-
+#include "servers/physics_2d_server.h"
class SpatialIndexer2D;
class VisibilityNotifier2D;
@@ -68,6 +68,8 @@ public:
RID get_space();
RID get_sound_space();
+ Physics2DDirectSpaceState *get_direct_space_state();
+
World2D();
~World2D();
};
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index af5e6d4165..d4159f0946 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -41,6 +41,7 @@ SceneStringNames::SceneStringNames() {
visibility_changed=StaticCString::create("visibility_changed");
input_event=StaticCString::create("input_event");
shader_shader=StaticCString::create("shader/shader");
+ shader_unshaded=StaticCString::create("shader/unshaded");
enter_tree=StaticCString::create("enter_tree");
exit_tree=StaticCString::create("exit_tree");
item_rect_changed=StaticCString::create("item_rect_changed");
@@ -63,6 +64,9 @@ SceneStringNames::SceneStringNames() {
body_exit_shape = StaticCString::create("body_exit_shape");
body_exit = StaticCString::create("body_exit");
+ area_enter_shape = StaticCString::create("area_enter_shape");
+ area_exit_shape = StaticCString::create("area_exit_shape");
+
idle=StaticCString::create("idle");
iteration=StaticCString::create("iteration");
@@ -102,6 +106,9 @@ SceneStringNames::SceneStringNames() {
_body_enter_tree = StaticCString::create("_body_enter_tree");
_body_exit_tree = StaticCString::create("_body_exit_tree");
+ _area_enter_tree = StaticCString::create("_area_enter_tree");
+ _area_exit_tree = StaticCString::create("_area_exit_tree");
+
_input_event=StaticCString::create("_input_event");
changed=StaticCString::create("changed");
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 14e5e83b8d..aa29ef57dc 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -56,6 +56,7 @@ public:
StringName _input_event;
StringName item_rect_changed;
StringName shader_shader;
+ StringName shader_unshaded;
StringName enter_tree;
StringName exit_tree;
StringName size_flags_changed;
@@ -82,6 +83,10 @@ public:
StringName body_exit_shape;
StringName body_exit;
+ StringName area_enter_shape;
+ StringName area_exit_shape;
+
+
StringName _get_gizmo_geometry;
StringName _can_gizmo_scale;
@@ -123,6 +128,9 @@ public:
StringName _body_enter_tree;
StringName _body_exit_tree;
+ StringName _area_enter_tree;
+ StringName _area_exit_tree;
+
StringName changed;
StringName _shader_changed;