diff options
Diffstat (limited to 'scene/2d')
64 files changed, 1494 insertions, 2100 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 73774e12d9..64d6ef5560 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -222,32 +222,32 @@ void SpriteFrames::_set_animations(const Array& p_animations) { void SpriteFrames::_bind_methods() { - ObjectTypeDB::bind_method(_MD("add_animation","anim"),&SpriteFrames::add_animation); - ObjectTypeDB::bind_method(_MD("has_animation","anim"),&SpriteFrames::has_animation); - ObjectTypeDB::bind_method(_MD("remove_animation","anim"),&SpriteFrames::remove_animation); - ObjectTypeDB::bind_method(_MD("rename_animation","anim","newname"),&SpriteFrames::rename_animation); + ClassDB::bind_method(_MD("add_animation","anim"),&SpriteFrames::add_animation); + ClassDB::bind_method(_MD("has_animation","anim"),&SpriteFrames::has_animation); + ClassDB::bind_method(_MD("remove_animation","anim"),&SpriteFrames::remove_animation); + ClassDB::bind_method(_MD("rename_animation","anim","newname"),&SpriteFrames::rename_animation); - ObjectTypeDB::bind_method(_MD("set_animation_speed","anim","speed"),&SpriteFrames::set_animation_speed); - ObjectTypeDB::bind_method(_MD("get_animation_speed","anim"),&SpriteFrames::get_animation_speed); + ClassDB::bind_method(_MD("set_animation_speed","anim","speed"),&SpriteFrames::set_animation_speed); + ClassDB::bind_method(_MD("get_animation_speed","anim"),&SpriteFrames::get_animation_speed); - ObjectTypeDB::bind_method(_MD("set_animation_loop","anim","loop"),&SpriteFrames::set_animation_loop); - ObjectTypeDB::bind_method(_MD("get_animation_loop","anim"),&SpriteFrames::get_animation_loop); + ClassDB::bind_method(_MD("set_animation_loop","anim","loop"),&SpriteFrames::set_animation_loop); + ClassDB::bind_method(_MD("get_animation_loop","anim"),&SpriteFrames::get_animation_loop); - ObjectTypeDB::bind_method(_MD("add_frame","anim","frame","atpos"),&SpriteFrames::add_frame,DEFVAL(-1)); - ObjectTypeDB::bind_method(_MD("get_frame_count","anim"),&SpriteFrames::get_frame_count); - ObjectTypeDB::bind_method(_MD("get_frame","anim","idx"),&SpriteFrames::get_frame); - ObjectTypeDB::bind_method(_MD("set_frame","anim","idx","txt"),&SpriteFrames::set_frame); - ObjectTypeDB::bind_method(_MD("remove_frame","anim","idx"),&SpriteFrames::remove_frame); - ObjectTypeDB::bind_method(_MD("clear","anim"),&SpriteFrames::clear); - ObjectTypeDB::bind_method(_MD("clear_all"),&SpriteFrames::clear_all); + ClassDB::bind_method(_MD("add_frame","anim","frame","atpos"),&SpriteFrames::add_frame,DEFVAL(-1)); + ClassDB::bind_method(_MD("get_frame_count","anim"),&SpriteFrames::get_frame_count); + ClassDB::bind_method(_MD("get_frame","anim","idx"),&SpriteFrames::get_frame); + ClassDB::bind_method(_MD("set_frame","anim","idx","txt"),&SpriteFrames::set_frame); + ClassDB::bind_method(_MD("remove_frame","anim","idx"),&SpriteFrames::remove_frame); + ClassDB::bind_method(_MD("clear","anim"),&SpriteFrames::clear); + ClassDB::bind_method(_MD("clear_all"),&SpriteFrames::clear_all); - ObjectTypeDB::bind_method(_MD("_set_frames"),&SpriteFrames::_set_frames); - ObjectTypeDB::bind_method(_MD("_get_frames"),&SpriteFrames::_get_frames); + ClassDB::bind_method(_MD("_set_frames"),&SpriteFrames::_set_frames); + ClassDB::bind_method(_MD("_get_frames"),&SpriteFrames::_get_frames); ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"frames",PROPERTY_HINT_NONE,"",0),_SCS("_set_frames"),_SCS("_get_frames")); //compatibility - ObjectTypeDB::bind_method(_MD("_set_animations"),&SpriteFrames::_set_animations); - ObjectTypeDB::bind_method(_MD("_get_animations"),&SpriteFrames::_get_animations); + ClassDB::bind_method(_MD("_set_animations"),&SpriteFrames::_set_animations); + ClassDB::bind_method(_MD("_get_animations"),&SpriteFrames::_get_animations); ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"animations",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_animations"),_SCS("_get_animations")); //compatibility @@ -332,7 +332,7 @@ void AnimatedSprite::_validate_property(PropertyInfo& property) const { void AnimatedSprite::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_PROCESS: { + case NOTIFICATION_INTERNAL_PROCESS: { if (frames.is_null()) return; @@ -362,6 +362,9 @@ void AnimatedSprite::_notification(int p_what) { } } else { frame++; + if (frame==fc-1) { + emit_signal(SceneStringNames::get_singleton()->animation_finished); + } } update(); @@ -414,7 +417,7 @@ void AnimatedSprite::_notification(int p_what) { if (centered) ofs-=s/2; - if (OS::get_singleton()->get_use_pixel_snap()) { + if (Engine::get_singleton()->get_use_pixel_snap()) { ofs=ofs.floor(); } Rect2 dst_rect(ofs,s); @@ -425,8 +428,8 @@ void AnimatedSprite::_notification(int p_what) { dst_rect.size.y=-dst_rect.size.y; //texture->draw_rect(ci,dst_rect,false,modulate); - texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()),modulate); -// VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate); + texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size())); + //VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate); } break; } @@ -541,17 +544,6 @@ bool AnimatedSprite::is_flipped_v() const { } -void AnimatedSprite::set_modulate(const Color& p_color) { - - modulate=p_color; - update(); -} - -Color AnimatedSprite::get_modulate() const{ - - return modulate; -} - Rect2 AnimatedSprite::get_item_rect() const { @@ -590,7 +582,7 @@ void AnimatedSprite::_set_playing(bool p_playing) { return; playing=p_playing; _reset_timeout(); - set_process(playing); + set_process_internal(playing); } bool AnimatedSprite::_is_playing() const { @@ -661,41 +653,39 @@ String AnimatedSprite::get_configuration_warning() const { void AnimatedSprite::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite::set_sprite_frames); - ObjectTypeDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite::get_sprite_frames); + ClassDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite::set_sprite_frames); + ClassDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite::get_sprite_frames); - ObjectTypeDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite::set_animation); - ObjectTypeDB::bind_method(_MD("get_animation"),&AnimatedSprite::get_animation); + ClassDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite::set_animation); + ClassDB::bind_method(_MD("get_animation"),&AnimatedSprite::get_animation); - ObjectTypeDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite::_set_playing); - ObjectTypeDB::bind_method(_MD("_is_playing"),&AnimatedSprite::_is_playing); + ClassDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite::_set_playing); + ClassDB::bind_method(_MD("_is_playing"),&AnimatedSprite::_is_playing); - ObjectTypeDB::bind_method(_MD("play","anim"),&AnimatedSprite::play,DEFVAL(StringName())); - ObjectTypeDB::bind_method(_MD("stop"),&AnimatedSprite::stop); - ObjectTypeDB::bind_method(_MD("is_playing"),&AnimatedSprite::is_playing); + ClassDB::bind_method(_MD("play","anim"),&AnimatedSprite::play,DEFVAL(StringName())); + ClassDB::bind_method(_MD("stop"),&AnimatedSprite::stop); + ClassDB::bind_method(_MD("is_playing"),&AnimatedSprite::is_playing); - ObjectTypeDB::bind_method(_MD("set_centered","centered"),&AnimatedSprite::set_centered); - ObjectTypeDB::bind_method(_MD("is_centered"),&AnimatedSprite::is_centered); + ClassDB::bind_method(_MD("set_centered","centered"),&AnimatedSprite::set_centered); + ClassDB::bind_method(_MD("is_centered"),&AnimatedSprite::is_centered); - ObjectTypeDB::bind_method(_MD("set_offset","offset"),&AnimatedSprite::set_offset); - ObjectTypeDB::bind_method(_MD("get_offset"),&AnimatedSprite::get_offset); + ClassDB::bind_method(_MD("set_offset","offset"),&AnimatedSprite::set_offset); + ClassDB::bind_method(_MD("get_offset"),&AnimatedSprite::get_offset); - ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&AnimatedSprite::set_flip_h); - ObjectTypeDB::bind_method(_MD("is_flipped_h"),&AnimatedSprite::is_flipped_h); + ClassDB::bind_method(_MD("set_flip_h","flip_h"),&AnimatedSprite::set_flip_h); + ClassDB::bind_method(_MD("is_flipped_h"),&AnimatedSprite::is_flipped_h); - ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&AnimatedSprite::set_flip_v); - ObjectTypeDB::bind_method(_MD("is_flipped_v"),&AnimatedSprite::is_flipped_v); + ClassDB::bind_method(_MD("set_flip_v","flip_v"),&AnimatedSprite::set_flip_v); + ClassDB::bind_method(_MD("is_flipped_v"),&AnimatedSprite::is_flipped_v); - ObjectTypeDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite::set_frame); - ObjectTypeDB::bind_method(_MD("get_frame"),&AnimatedSprite::get_frame); + ClassDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite::set_frame); + ClassDB::bind_method(_MD("get_frame"),&AnimatedSprite::get_frame); - ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&AnimatedSprite::set_modulate); - ObjectTypeDB::bind_method(_MD("get_modulate"),&AnimatedSprite::get_modulate); - - ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed); + ClassDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed); ADD_SIGNAL(MethodInfo("frame_changed")); + ADD_SIGNAL(MethodInfo("animation_finished")); ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames")); ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation")); @@ -705,7 +695,7 @@ void AnimatedSprite::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset")); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h")); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v")); - ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); + } @@ -718,7 +708,6 @@ AnimatedSprite::AnimatedSprite() { frame=0; playing=false; animation="default"; - modulate=Color(1,1,1,1); timeout=0; diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 968cd9aa30..fbeea7f69b 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class SpriteFrames : public Resource { - OBJ_TYPE(SpriteFrames,Resource); + GDCLASS(SpriteFrames,Resource); struct Anim { @@ -109,7 +109,7 @@ public: class AnimatedSprite : public Node2D { - OBJ_TYPE(AnimatedSprite,Node2D); + GDCLASS(AnimatedSprite,Node2D); Ref<SpriteFrames> frames; bool playing; @@ -124,7 +124,6 @@ class AnimatedSprite : public Node2D { bool hflip; bool vflip; - Color modulate; void _res_changed(); diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index e8954b7e98..61ed362cf0 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -127,10 +127,10 @@ void Area2D::_body_enter_tree(ObjectID p_id) { ERR_FAIL_COND(E->get().in_tree); E->get().in_tree=true; - emit_signal(SceneStringNames::get_singleton()->body_enter,node); + emit_signal(SceneStringNames::get_singleton()->body_entered,node); for(int i=0;i<E->get().shapes.size();i++) { - emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_entered,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape); } } @@ -144,10 +144,10 @@ void Area2D::_body_exit_tree(ObjectID p_id) { ERR_FAIL_COND(!E); ERR_FAIL_COND(!E->get().in_tree); E->get().in_tree=false; - emit_signal(SceneStringNames::get_singleton()->body_exit,node); + emit_signal(SceneStringNames::get_singleton()->body_exited,node); for(int i=0;i<E->get().shapes.size();i++) { - emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_exited,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape); } } @@ -173,10 +173,10 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b 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()->_body_enter_tree,make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid)); if (E->get().in_tree) { - emit_signal(SceneStringNames::get_singleton()->body_enter,node); + emit_signal(SceneStringNames::get_singleton()->body_entered,node); } } @@ -187,7 +187,7 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b if (!node || E->get().in_tree) { - emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_area_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_entered,objid,node,p_body_shape,p_area_shape); } } else { @@ -202,10 +202,10 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b if (E->get().rc==0) { if (node) { - 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); + node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree); if (E->get().in_tree) - emit_signal(SceneStringNames::get_singleton()->body_exit,obj); + emit_signal(SceneStringNames::get_singleton()->body_exited,obj); } @@ -213,7 +213,7 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b } if (!node || E->get().in_tree) { - emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_area_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_exited,objid,obj,p_body_shape,p_area_shape); } if (eraseit) @@ -239,10 +239,10 @@ void Area2D::_area_enter_tree(ObjectID p_id) { ERR_FAIL_COND(E->get().in_tree); E->get().in_tree=true; - emit_signal(SceneStringNames::get_singleton()->area_enter,node); + emit_signal(SceneStringNames::get_singleton()->area_entered,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); + emit_signal(SceneStringNames::get_singleton()->area_shape_entered,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape); } } @@ -256,10 +256,10 @@ void Area2D::_area_exit_tree(ObjectID 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); + emit_signal(SceneStringNames::get_singleton()->area_exited,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); + emit_signal(SceneStringNames::get_singleton()->area_shape_exited,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape); } } @@ -285,10 +285,10 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a 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)); + node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid)); if (E->get().in_tree) { - emit_signal(SceneStringNames::get_singleton()->area_enter,node); + emit_signal(SceneStringNames::get_singleton()->area_entered,node); } } @@ -299,7 +299,7 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a if (!node || E->get().in_tree) { - emit_signal(SceneStringNames::get_singleton()->area_enter_shape,objid,node,p_area_shape,p_self_shape); + emit_signal(SceneStringNames::get_singleton()->area_shape_entered,objid,node,p_area_shape,p_self_shape); } } else { @@ -314,10 +314,10 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a 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); + node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree); if (E->get().in_tree) - emit_signal(SceneStringNames::get_singleton()->area_exit,obj); + emit_signal(SceneStringNames::get_singleton()->area_exited,obj); } @@ -325,7 +325,7 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a } if (!node || E->get().in_tree) { - emit_signal(SceneStringNames::get_singleton()->area_exit_shape,objid,obj,p_area_shape,p_self_shape); + emit_signal(SceneStringNames::get_singleton()->area_shape_exited,objid,obj,p_area_shape,p_self_shape); } if (eraseit) @@ -362,13 +362,13 @@ void Area2D::_clear_monitoring() { 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_shape_exited,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape); } - emit_signal(SceneStringNames::get_singleton()->body_exit,obj); + emit_signal(SceneStringNames::get_singleton()->body_exited,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); + node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree); } } @@ -393,13 +393,13 @@ void Area2D::_clear_monitoring() { 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_shape_exited,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape); } - emit_signal(SceneStringNames::get_singleton()->area_exit,obj); + emit_signal(SceneStringNames::get_singleton()->area_exited,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); + node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_area_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_area_exit_tree); } } @@ -418,7 +418,7 @@ void Area2D::_notification(int p_what) { } -void Area2D::set_enable_monitoring(bool p_enable) { +void Area2D::set_monitoring(bool p_enable) { if (p_enable==monitoring) @@ -443,7 +443,7 @@ void Area2D::set_enable_monitoring(bool p_enable) { } } -bool Area2D::is_monitoring_enabled() const { +bool Area2D::is_monitoring() const { return monitoring; } @@ -587,73 +587,73 @@ bool Area2D::get_layer_mask_bit(int p_bit) const{ 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); + ClassDB::bind_method(_MD("_body_enter_tree","id"),&Area2D::_body_enter_tree); + ClassDB::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); + ClassDB::bind_method(_MD("_area_enter_tree","id"),&Area2D::_area_enter_tree); + ClassDB::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); + ClassDB::bind_method(_MD("set_space_override_mode","enable"),&Area2D::set_space_override_mode); + ClassDB::bind_method(_MD("get_space_override_mode"),&Area2D::get_space_override_mode); - ObjectTypeDB::bind_method(_MD("set_gravity_is_point","enable"),&Area2D::set_gravity_is_point); - ObjectTypeDB::bind_method(_MD("is_gravity_a_point"),&Area2D::is_gravity_a_point); + ClassDB::bind_method(_MD("set_gravity_is_point","enable"),&Area2D::set_gravity_is_point); + ClassDB::bind_method(_MD("is_gravity_a_point"),&Area2D::is_gravity_a_point); - ObjectTypeDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area2D::set_gravity_distance_scale); - ObjectTypeDB::bind_method(_MD("get_gravity_distance_scale"),&Area2D::get_gravity_distance_scale); + ClassDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area2D::set_gravity_distance_scale); + ClassDB::bind_method(_MD("get_gravity_distance_scale"),&Area2D::get_gravity_distance_scale); - ObjectTypeDB::bind_method(_MD("set_gravity_vector","vector"),&Area2D::set_gravity_vector); - ObjectTypeDB::bind_method(_MD("get_gravity_vector"),&Area2D::get_gravity_vector); + ClassDB::bind_method(_MD("set_gravity_vector","vector"),&Area2D::set_gravity_vector); + ClassDB::bind_method(_MD("get_gravity_vector"),&Area2D::get_gravity_vector); - ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&Area2D::set_gravity); - ObjectTypeDB::bind_method(_MD("get_gravity"),&Area2D::get_gravity); + ClassDB::bind_method(_MD("set_gravity","gravity"),&Area2D::set_gravity); + ClassDB::bind_method(_MD("get_gravity"),&Area2D::get_gravity); - ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area2D::set_linear_damp); - ObjectTypeDB::bind_method(_MD("get_linear_damp"),&Area2D::get_linear_damp); + ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area2D::set_linear_damp); + ClassDB::bind_method(_MD("get_linear_damp"),&Area2D::get_linear_damp); - ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area2D::set_angular_damp); - ObjectTypeDB::bind_method(_MD("get_angular_damp"),&Area2D::get_angular_damp); + ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area2D::set_angular_damp); + ClassDB::bind_method(_MD("get_angular_damp"),&Area2D::get_angular_damp); - ObjectTypeDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority); - ObjectTypeDB::bind_method(_MD("get_priority"),&Area2D::get_priority); + ClassDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority); + ClassDB::bind_method(_MD("get_priority"),&Area2D::get_priority); - ObjectTypeDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask); - ObjectTypeDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask); + ClassDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask); + ClassDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask); - ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask); - ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask); + ClassDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask); + ClassDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask); - ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit); - ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit); + ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit); + ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit); - ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit); - ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit); + ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit); + ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit); - ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring); - ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled); + ClassDB::bind_method(_MD("set_monitoring","enable"),&Area2D::set_monitoring); + ClassDB::bind_method(_MD("is_monitoring"),&Area2D::is_monitoring); - ObjectTypeDB::bind_method(_MD("set_monitorable","enable"),&Area2D::set_monitorable); - ObjectTypeDB::bind_method(_MD("is_monitorable"),&Area2D::is_monitorable); + ClassDB::bind_method(_MD("set_monitorable","enable"),&Area2D::set_monitorable); + ClassDB::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); + ClassDB::bind_method(_MD("get_overlapping_bodies"),&Area2D::get_overlapping_bodies); + ClassDB::bind_method(_MD("get_overlapping_areas"),&Area2D::get_overlapping_areas); - ObjectTypeDB::bind_method(_MD("overlaps_body","body"),&Area2D::overlaps_body); - ObjectTypeDB::bind_method(_MD("overlaps_area","area"),&Area2D::overlaps_area); + ClassDB::bind_method(_MD("overlaps_body","body"),&Area2D::overlaps_body); + ClassDB::bind_method(_MD("overlaps_area","area"),&Area2D::overlaps_area); - ObjectTypeDB::bind_method(_MD("_body_inout"),&Area2D::_body_inout); - ObjectTypeDB::bind_method(_MD("_area_inout"),&Area2D::_area_inout); + ClassDB::bind_method(_MD("_body_inout"),&Area2D::_body_inout); + ClassDB::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("body_shape_entered",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_shape_exited",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_entered",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"))); + ADD_SIGNAL( MethodInfo("body_exited",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,"self_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,"self_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("area_shape_entered",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); + ADD_SIGNAL( MethodInfo("area_shape_exited",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); + ADD_SIGNAL( MethodInfo("area_entered",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"))); + ADD_SIGNAL( MethodInfo("area_exited",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"))); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode")); @@ -664,17 +664,18 @@ void Area2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp")); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority")); - ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled")); + ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_monitoring"),_SCS("is_monitoring")); ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable")); - ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); - ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + ADD_GROUP("Collision","collision_"); + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); } Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_create(),true) { space_override=SPACE_OVERRIDE_DISABLED; - set_gravity(98);; + set_gravity(98); set_gravity_vector(Vector2(0,1)); gravity_is_point=false; gravity_distance_scale=0; @@ -686,7 +687,7 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea monitorable=false; collision_mask=1; layer_mask=1; - set_enable_monitoring(true); + set_monitoring(true); set_monitorable(true); } diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 7f3f9c93cf..68bada707b 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class Area2D : public CollisionObject2D { - OBJ_TYPE( Area2D, CollisionObject2D ); + GDCLASS( Area2D, CollisionObject2D ); public: enum SpaceOverride { @@ -153,8 +153,8 @@ public: void set_priority(real_t p_priority); real_t get_priority() const; - void set_enable_monitoring(bool p_enable); - bool is_monitoring_enabled() const; + void set_monitoring(bool p_enable); + bool is_monitoring() const; void set_monitorable(bool p_enable); bool is_monitorable() const; diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp index a83a3ce041..bbeed322b1 100644 --- a/scene/2d/back_buffer_copy.cpp +++ b/scene/2d/back_buffer_copy.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -77,11 +77,11 @@ BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const{ void BackBufferCopy::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_rect","rect"),&BackBufferCopy::set_rect); - ObjectTypeDB::bind_method(_MD("get_rect"),&BackBufferCopy::get_rect); + ClassDB::bind_method(_MD("set_rect","rect"),&BackBufferCopy::set_rect); + ClassDB::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); + ClassDB::bind_method(_MD("set_copy_mode","copy_mode"),&BackBufferCopy::set_copy_mode); + ClassDB::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")); diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h index f371dbdef4..22387f3e9d 100644 --- a/scene/2d/back_buffer_copy.h +++ b/scene/2d/back_buffer_copy.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -32,7 +32,7 @@ #include "scene/2d/node_2d.h" class BackBufferCopy : public Node2D { - OBJ_TYPE( BackBufferCopy,Node2D); + GDCLASS( BackBufferCopy,Node2D); public: enum CopyMode { COPY_MODE_DISABLED, diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index f33faaabd8..0bafef1b83 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -47,12 +47,12 @@ void Camera2D::_update_scroll() { ERR_FAIL_COND( custom_viewport && !ObjectDB::get_instance(custom_viewport_id) ); - Matrix32 xform = get_camera_transform(); + Transform2D xform = get_camera_transform(); if (viewport) { viewport->set_canvas_transform( xform ); } - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform); }; } @@ -71,12 +71,12 @@ Vector2 Camera2D::get_zoom() const { }; -Matrix32 Camera2D::get_camera_transform() { +Transform2D Camera2D::get_camera_transform() { if (!get_tree()) - return Matrix32(); + return Transform2D(); - ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Matrix32() ); + ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D() ); Size2 screen_size = viewport->get_visible_rect().size; @@ -145,7 +145,7 @@ Matrix32 Camera2D::get_camera_transform() { float c = smoothing*get_fixed_process_delta_time(); smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos; ret_camera_pos=smoothed_camera_pos; - // camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing; + //camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing; } else { ret_camera_pos=smoothed_camera_pos=camera_pos; @@ -201,7 +201,7 @@ Matrix32 Camera2D::get_camera_transform() { camera_screen_center=screen_rect.pos+screen_rect.size*0.5; - Matrix32 xform; + Transform2D xform; if(rotating){ xform.set_rotation(angle); } @@ -252,7 +252,7 @@ void Camera2D::_notification(int p_what) { canvas = get_canvas(); - RID vp = viewport->get_viewport(); + RID vp = viewport->get_viewport_rid(); group_name = "__cameras_"+itos(vp.get_id()); canvas_group_name ="__cameras_c"+itos(canvas.get_id()); @@ -272,7 +272,7 @@ void Camera2D::_notification(int p_what) { if (is_current()) { if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) { - viewport->set_canvas_transform( Matrix32() ); + viewport->set_canvas_transform( Transform2D() ); } } remove_from_group(group_name); @@ -290,7 +290,7 @@ void Camera2D::_notification(int p_what) { if(current) area_axis_width = 3; - Matrix32 inv_camera_transform = get_camera_transform().affine_inverse(); + Transform2D inv_camera_transform = get_camera_transform().affine_inverse(); Size2 screen_size = get_viewport_rect().size; Vector2 screen_endpoints[4]= { @@ -300,7 +300,7 @@ void Camera2D::_notification(int p_what) { inv_camera_transform.xform(Vector2(0, screen_size.height)) }; - Matrix32 inv_transform = get_global_transform().affine_inverse(); // undo global space + Transform2D inv_transform = get_global_transform().affine_inverse(); // undo global space for(int i=0;i<4;i++) { draw_line(inv_transform.xform(screen_endpoints[i]), inv_transform.xform(screen_endpoints[(i+1)%4]), area_axis_color, area_axis_width); @@ -375,7 +375,7 @@ void Camera2D::make_current() { if (!is_inside_tree()) { current=true; } else { - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this); } } @@ -383,7 +383,7 @@ void Camera2D::clear_current() { current=false; if (is_inside_tree()) { - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL)); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL)); } } @@ -573,7 +573,7 @@ void Camera2D::set_custom_viewport(Node *p_viewport) { else viewport=get_viewport(); - RID vp = viewport->get_viewport(); + RID vp = viewport->get_viewport_rid(); group_name = "__cameras_"+itos(vp.get_id()); canvas_group_name ="__cameras_c"+itos(canvas.get_id()); add_to_group(group_name); @@ -590,65 +590,65 @@ Node* Camera2D::get_custom_viewport() const { void Camera2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset); - ObjectTypeDB::bind_method(_MD("get_offset"),&Camera2D::get_offset); + ClassDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset); + ClassDB::bind_method(_MD("get_offset"),&Camera2D::get_offset); - ObjectTypeDB::bind_method(_MD("set_anchor_mode","anchor_mode"),&Camera2D::set_anchor_mode); - ObjectTypeDB::bind_method(_MD("get_anchor_mode"),&Camera2D::get_anchor_mode); + ClassDB::bind_method(_MD("set_anchor_mode","anchor_mode"),&Camera2D::set_anchor_mode); + ClassDB::bind_method(_MD("get_anchor_mode"),&Camera2D::get_anchor_mode); - ObjectTypeDB::bind_method(_MD("set_rotating","rotating"),&Camera2D::set_rotating); - ObjectTypeDB::bind_method(_MD("is_rotating"),&Camera2D::is_rotating); + ClassDB::bind_method(_MD("set_rotating","rotating"),&Camera2D::set_rotating); + ClassDB::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); + ClassDB::bind_method(_MD("make_current"),&Camera2D::make_current); + ClassDB::bind_method(_MD("clear_current"),&Camera2D::clear_current); + ClassDB::bind_method(_MD("_make_current"),&Camera2D::_make_current); - ObjectTypeDB::bind_method(_MD("_update_scroll"),&Camera2D::_update_scroll); + ClassDB::bind_method(_MD("_update_scroll"),&Camera2D::_update_scroll); - ObjectTypeDB::bind_method(_MD("_set_current","current"),&Camera2D::_set_current); - ObjectTypeDB::bind_method(_MD("is_current"),&Camera2D::is_current); + ClassDB::bind_method(_MD("_set_current","current"),&Camera2D::_set_current); + ClassDB::bind_method(_MD("is_current"),&Camera2D::is_current); - ObjectTypeDB::bind_method(_MD("set_limit","margin","limit"),&Camera2D::set_limit); - ObjectTypeDB::bind_method(_MD("get_limit","margin"),&Camera2D::get_limit); + ClassDB::bind_method(_MD("set_limit","margin","limit"),&Camera2D::set_limit); + ClassDB::bind_method(_MD("get_limit","margin"),&Camera2D::get_limit); - ObjectTypeDB::bind_method(_MD("set_limit_smoothing_enabled","limit_smoothing_enabled"),&Camera2D::set_limit_smoothing_enabled); - ObjectTypeDB::bind_method(_MD("is_limit_smoothing_enabled"),&Camera2D::is_limit_smoothing_enabled); + ClassDB::bind_method(_MD("set_limit_smoothing_enabled","limit_smoothing_enabled"),&Camera2D::set_limit_smoothing_enabled); + ClassDB::bind_method(_MD("is_limit_smoothing_enabled"),&Camera2D::is_limit_smoothing_enabled); - ObjectTypeDB::bind_method(_MD("set_v_drag_enabled","enabled"),&Camera2D::set_v_drag_enabled); - ObjectTypeDB::bind_method(_MD("is_v_drag_enabled"),&Camera2D::is_v_drag_enabled); + ClassDB::bind_method(_MD("set_v_drag_enabled","enabled"),&Camera2D::set_v_drag_enabled); + ClassDB::bind_method(_MD("is_v_drag_enabled"),&Camera2D::is_v_drag_enabled); - ObjectTypeDB::bind_method(_MD("set_h_drag_enabled","enabled"),&Camera2D::set_h_drag_enabled); - ObjectTypeDB::bind_method(_MD("is_h_drag_enabled"),&Camera2D::is_h_drag_enabled); + ClassDB::bind_method(_MD("set_h_drag_enabled","enabled"),&Camera2D::set_h_drag_enabled); + ClassDB::bind_method(_MD("is_h_drag_enabled"),&Camera2D::is_h_drag_enabled); - ObjectTypeDB::bind_method(_MD("set_v_offset","ofs"),&Camera2D::set_v_offset); - ObjectTypeDB::bind_method(_MD("get_v_offset"),&Camera2D::get_v_offset); + ClassDB::bind_method(_MD("set_v_offset","ofs"),&Camera2D::set_v_offset); + ClassDB::bind_method(_MD("get_v_offset"),&Camera2D::get_v_offset); - ObjectTypeDB::bind_method(_MD("set_h_offset","ofs"),&Camera2D::set_h_offset); - ObjectTypeDB::bind_method(_MD("get_h_offset"),&Camera2D::get_h_offset); + ClassDB::bind_method(_MD("set_h_offset","ofs"),&Camera2D::set_h_offset); + ClassDB::bind_method(_MD("get_h_offset"),&Camera2D::get_h_offset); - ObjectTypeDB::bind_method(_MD("set_drag_margin","margin","drag_margin"),&Camera2D::set_drag_margin); - ObjectTypeDB::bind_method(_MD("get_drag_margin","margin"),&Camera2D::get_drag_margin); + ClassDB::bind_method(_MD("set_drag_margin","margin","drag_margin"),&Camera2D::set_drag_margin); + ClassDB::bind_method(_MD("get_drag_margin","margin"),&Camera2D::get_drag_margin); - ObjectTypeDB::bind_method(_MD("get_camera_pos"),&Camera2D::get_camera_pos); - ObjectTypeDB::bind_method(_MD("get_camera_screen_center"),&Camera2D::get_camera_screen_center); + ClassDB::bind_method(_MD("get_camera_pos"),&Camera2D::get_camera_pos); + ClassDB::bind_method(_MD("get_camera_screen_center"),&Camera2D::get_camera_screen_center); - ObjectTypeDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom); - ObjectTypeDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom); + ClassDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom); + ClassDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom); - ObjectTypeDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport); - ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport); + ClassDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport); + ClassDB::bind_method(_MD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport); - ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing); - ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing); + ClassDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing); + ClassDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing); - ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing); - ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled); + ClassDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing); + ClassDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled); - ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll); - ObjectTypeDB::bind_method(_MD("reset_smoothing"),&Camera2D::reset_smoothing); - ObjectTypeDB::bind_method(_MD("align"),&Camera2D::align); + ClassDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll); + ClassDB::bind_method(_MD("reset_smoothing"),&Camera2D::reset_smoothing); + ClassDB::bind_method(_MD("align"),&Camera2D::align); - ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing); + ClassDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset")); ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode")); @@ -656,25 +656,26 @@ void Camera2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") ); - ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT); - ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/top"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_TOP); - ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/right"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_RIGHT); - ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/bottom"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_BOTTOM); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"limit/smoothed"),_SCS("set_limit_smoothing_enabled"),_SCS("is_limit_smoothing_enabled") ); + ADD_GROUP("Limit","limit_"); + ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT); + ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_top"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_TOP); + ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_right"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_RIGHT); + ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit_bottom"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_BOTTOM); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"limit_smoothed"),_SCS("set_limit_smoothing_enabled"),_SCS("is_limit_smoothing_enabled") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") ); + ADD_GROUP("Draw Margin","draw_margin_"); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin_v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing/enable"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") ); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing/speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") ); + ADD_GROUP("Smoothing","smoothing_"); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing_enabled"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing_speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") ); - //compatibility - ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing",PROPERTY_HINT_NONE,"",0),_SCS("_set_old_smoothing"),_SCS("get_follow_smoothing") ); - - ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT); - ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP); - ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT); - ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/bottom",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_BOTTOM); + ADD_GROUP("Drag Margin","drag_margin_"); + ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT); + ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP); + ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT); + ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin_bottom",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_BOTTOM); BIND_CONSTANT( ANCHOR_MODE_DRAG_CENTER ); @@ -712,5 +713,6 @@ Camera2D::Camera2D() { v_drag_enabled=true; h_ofs=0; v_ofs=0; + set_notify_transform(true); } diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index a4d6dc5b96..85d90b225a 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class Camera2D : public Node2D { - OBJ_TYPE( Camera2D, Node2D ); + GDCLASS( Camera2D, Node2D ); public: enum AnchorMode { @@ -80,7 +80,7 @@ protected: void _set_old_smoothing(float p_enable); protected: - virtual Matrix32 get_camera_transform(); + virtual Transform2D get_camera_transform(); void _notification(int p_what); static void _bind_methods(); public: diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index ed1d606ba8..817707f96e 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -42,9 +42,6 @@ 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()->shading_mode) { - set_shading_mode(ShadingMode(p_value.operator int())); - return true; } else { if (shader.is_valid()) { @@ -58,7 +55,7 @@ bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value) } } if (pr) { - VisualServer::get_singleton()->canvas_item_material_set_shader_param(material,pr,p_value); + VisualServer::get_singleton()->material_set_param(_get_material(),pr,p_value); return true; } } @@ -74,18 +71,14 @@ bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const { r_ret=get_shader(); return true; - } else if (p_name==SceneStringNames::get_singleton()->shading_mode) { - - r_ret=shading_mode; - 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); + r_ret=VisualServer::get_singleton()->material_get_param(_get_material(),pr); return true; } } @@ -100,7 +93,6 @@ bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const { 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::INT, "shader/shading_mode",PROPERTY_HINT_ENUM,"Normal,Unshaded,Light Only") ); if (!shader.is_null()) { @@ -119,7 +111,7 @@ void CanvasItemMaterial::set_shader(const Ref<Shader>& p_shader) { if (shader.is_valid()) rid=shader->get_rid(); - VS::get_singleton()->canvas_item_material_set_shader(material,rid); + VS::get_singleton()->material_set_shader(_get_material(),rid); _change_notify(); //properties for shader exposed emit_changed(); } @@ -131,42 +123,23 @@ Ref<Shader> CanvasItemMaterial::get_shader() const{ 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); + VS::get_singleton()->material_set_param(_get_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); -} - -RID CanvasItemMaterial::get_rid() const { - - return material; -} - -void CanvasItemMaterial::set_shading_mode(ShadingMode p_mode) { - - shading_mode=p_mode; - VS::get_singleton()->canvas_item_material_set_shading_mode(material,VS::CanvasItemShadingMode(p_mode)); + return VS::get_singleton()->material_get_param(_get_material(),p_param); } -CanvasItemMaterial::ShadingMode CanvasItemMaterial::get_shading_mode() const { - return shading_mode; -} 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_shading_mode","mode"),&CanvasItemMaterial::set_shading_mode); - ObjectTypeDB::bind_method(_MD("get_shading_mode"),&CanvasItemMaterial::get_shading_mode); + ClassDB::bind_method(_MD("set_shader","shader:Shader"),&CanvasItemMaterial::set_shader); + ClassDB::bind_method(_MD("get_shader:Shader"),&CanvasItemMaterial::get_shader); + ClassDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param); + ClassDB::bind_method(_MD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param); - BIND_CONSTANT( SHADING_NORMAL ); - BIND_CONSTANT( SHADING_UNSHADED ); - BIND_CONSTANT( SHADING_ONLY_LIGHT ); } @@ -189,13 +162,13 @@ void CanvasItemMaterial::get_argument_options(const StringName& p_function,int p CanvasItemMaterial::CanvasItemMaterial() { - material=VS::get_singleton()->canvas_item_material_create(); - shading_mode=SHADING_NORMAL; + + } CanvasItemMaterial::~CanvasItemMaterial(){ - VS::get_singleton()->free(material); + } @@ -209,7 +182,7 @@ CanvasItemMaterial::~CanvasItemMaterial(){ -bool CanvasItem::is_visible() const { +bool CanvasItem::is_visible_in_tree() const { if (!is_inside_tree()) return false; @@ -217,7 +190,7 @@ bool CanvasItem::is_visible() const { const CanvasItem *p=this; while(p) { - if (p->hidden) + if (!p->visible) return false; p=p->get_parent_item(); } @@ -226,13 +199,6 @@ bool CanvasItem::is_visible() const { return true; } -bool CanvasItem::is_hidden() const { - - /*if (!is_inside_scene()) - return false;*/ - - return hidden; -} void CanvasItem::_propagate_visibility_changed(bool p_visible) { @@ -248,7 +214,7 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) { CanvasItem *c=get_child(i)->cast_to<CanvasItem>(); - if (c && !c->hidden) //should the toplevels stop propagation? i think so but.. + if (c && c->visible) //should the toplevels stop propagation? i think so but.. c->_propagate_visibility_changed(p_visible); } @@ -258,50 +224,35 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) { void CanvasItem::show() { - if (!hidden) + if (visible) return; - - hidden=false; + visible=true; VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,true); if (!is_inside_tree()) return; - if (is_visible()) { - _propagate_visibility_changed(true); - } + _propagate_visibility_changed(true); _change_notify("visibility/visible"); } void CanvasItem::hide() { - if (hidden) + if (!visible) return; - bool propagate=is_inside_tree() && is_visible(); - hidden=true; + visible=false; VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false); if (!is_inside_tree()) return; - if (propagate) - _propagate_visibility_changed(false); + _propagate_visibility_changed(false); _change_notify("visibility/visible"); } -void CanvasItem::set_hidden(bool p_hidden) { - - if (hidden == p_hidden) { - return; - } - - _set_visible_(!p_hidden); -} - - Variant CanvasItem::edit_get_state() const { @@ -338,7 +289,7 @@ void CanvasItem::_update_callback() { VisualServer::get_singleton()->canvas_item_clear(get_canvas_item()); //todo updating = true - only allow drawing here - if (is_visible()) { //todo optimize this!! + if (is_visible_in_tree()) { //todo optimize this!! if (first_draw) { notification(NOTIFICATION_VISIBILITY_CHANGED); first_draw=false; @@ -357,10 +308,10 @@ void CanvasItem::_update_callback() { pending_update=false; // don't change to false until finished drawing (avoid recursive update) } -Matrix32 CanvasItem::get_global_transform_with_canvas() const { +Transform2D CanvasItem::get_global_transform_with_canvas() const { const CanvasItem *ci = this; - Matrix32 xform; + Transform2D xform; const CanvasItem *last_valid=NULL; while(ci) { @@ -374,9 +325,11 @@ Matrix32 CanvasItem::get_global_transform_with_canvas() const { return last_valid->canvas_layer->get_transform() * xform; else if (is_inside_tree()) return get_viewport()->get_canvas_transform() * xform; + + return xform; } -Matrix32 CanvasItem::get_global_transform() const { +Transform2D CanvasItem::get_global_transform() const { if (global_invalid) { @@ -394,42 +347,17 @@ Matrix32 CanvasItem::get_global_transform() const { } - -void CanvasItem::_queue_sort_children() { - - if (pending_children_sort) - return; - - pending_children_sort=true; - MessageQueue::get_singleton()->push_call(this,"_sort_children"); -} - -void CanvasItem::_sort_children() { - - pending_children_sort=false; +void CanvasItem::_toplevel_raise_self() { if (!is_inside_tree()) return; - for(int i=0;i<get_child_count();i++) { - - Node *n = get_child(i); - CanvasItem *ci=n->cast_to<CanvasItem>(); - - if (ci) { - if (ci->toplevel || ci->group!="") - continue; - VisualServer::get_singleton()->canvas_item_raise(n->cast_to<CanvasItem>()->canvas_item); - } - } -} - -void CanvasItem::_raise_self() { + if (canvas_layer) + VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,canvas_layer->get_sort_index()); + else + VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_viewport()->gui_get_canvas_sort_index()); - if (!is_inside_tree()) - return; - VisualServer::get_singleton()->canvas_item_raise(canvas_item); } @@ -461,14 +389,19 @@ void CanvasItem::_enter_canvas() { group = "root_canvas"+itos(canvas.get_id()); add_to_group(group); - get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self"); + if (canvas_layer) + canvas_layer->reset_sort_index(); + else + get_viewport()->gui_reset_canvas_sort_index(); + + get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self"); } else { CanvasItem *parent = get_parent_item(); canvas_layer=parent->canvas_layer; VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item()); - parent->_queue_sort_children(); + VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_index()); } pending_update=false; @@ -495,7 +428,6 @@ void CanvasItem::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { first_draw=true; - pending_children_sort=false; if (get_parent()) { CanvasItem *ci = get_parent()->cast_to<CanvasItem>(); if (ci) @@ -508,13 +440,15 @@ void CanvasItem::_notification(int p_what) { } break; case NOTIFICATION_MOVED_IN_PARENT: { + if (!is_inside_tree()) + break; if (group!="") { - get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self"); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self"); } else { CanvasItem *p = get_parent_item(); ERR_FAIL_COND(!p); - p->_queue_sort_children(); + VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_index()); } @@ -544,16 +478,16 @@ void CanvasItem::_notification(int p_what) { } } -void CanvasItem::_set_visible_(bool p_visible) { +void CanvasItem::set_visible(bool p_visible) { if (p_visible) show(); else hide(); } -bool CanvasItem::_is_visible_() const { +bool CanvasItem::is_visible() const { - return !is_hidden(); + return visible; } @@ -569,15 +503,15 @@ void CanvasItem::update() { MessageQueue::get_singleton()->push_call(this,"_update_callback"); } -void CanvasItem::set_opacity(float p_opacity) { +void CanvasItem::set_modulate(const Color& p_modulate) { - opacity=p_opacity; - VisualServer::get_singleton()->canvas_item_set_opacity(canvas_item,opacity); + modulate=p_modulate; + VisualServer::get_singleton()->canvas_item_set_modulate(canvas_item,modulate); } -float CanvasItem::get_opacity() const { +Color CanvasItem::get_modulate() const { - return opacity; + return modulate; } @@ -614,29 +548,17 @@ CanvasItem *CanvasItem::get_parent_item() const { } -void CanvasItem::set_self_opacity(float p_self_opacity) { - - self_opacity=p_self_opacity; - VisualServer::get_singleton()->canvas_item_set_self_opacity(canvas_item,self_opacity); +void CanvasItem::set_self_modulate(const Color& p_self_modulate) { -} -float CanvasItem::get_self_opacity() const { + self_modulate=p_self_modulate; + VisualServer::get_singleton()->canvas_item_set_self_modulate(canvas_item,self_modulate); - return self_opacity; } +Color CanvasItem::get_self_modulate() const { -void CanvasItem::set_blend_mode(BlendMode p_blend_mode) { - - ERR_FAIL_INDEX(p_blend_mode,5); - blend_mode=p_blend_mode; - VisualServer::get_singleton()->canvas_item_set_blend_mode(canvas_item,VS::MaterialBlendMode(blend_mode)); - + return self_modulate; } -CanvasItem::BlendMode CanvasItem::get_blend_mode() const { - - return blend_mode; -} void CanvasItem::set_light_mask(int p_light_mask) { @@ -752,12 +674,12 @@ void CanvasItem::draw_set_transform(const Point2& p_offset, float p_rot, const S ERR_FAIL(); } - Matrix32 xform(p_rot,p_offset); + Transform2D xform(p_rot,p_offset); xform.scale_basis(p_scale); VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,xform); } -void CanvasItem::draw_set_transform_matrix(const Matrix32& p_matrix) { +void CanvasItem::draw_set_transform_matrix(const Transform2D& p_matrix) { if (!drawing) { ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); @@ -830,7 +752,7 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) { p_node->global_invalid=true; - if (!p_node->xform_change.in_list()) { + if (notify_transform && !p_node->xform_change.in_list()) { if (!p_node->block_transform_notify) { if (p_node->is_inside_tree()) get_tree()->xform_change_list.add(&p_node->xform_change); @@ -896,7 +818,7 @@ Ref<World2D> CanvasItem::get_world_2d() const { RID CanvasItem::get_viewport_rid() const { ERR_FAIL_COND_V(!is_inside_tree(),RID()); - return get_viewport()->get_viewport(); + return get_viewport()->get_viewport_rid(); } void CanvasItem::set_block_transform_notify(bool p_enable) { @@ -913,7 +835,7 @@ void CanvasItem::set_draw_behind_parent(bool p_enable) { if (behind==p_enable) return; behind=p_enable; - VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,!behind); + VisualServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item,behind); } @@ -953,7 +875,7 @@ Vector2 CanvasItem::make_canvas_pos_local(const Vector2& screen_point) const { ERR_FAIL_COND_V(!is_inside_tree(),screen_point); - Matrix32 local_matrix = (get_canvas_transform() * + Transform2D local_matrix = (get_canvas_transform() * get_global_transform()).affine_inverse(); return local_matrix.xform(screen_point); @@ -983,101 +905,102 @@ Vector2 CanvasItem::get_local_mouse_pos() const{ void CanvasItem::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children); - ObjectTypeDB::bind_method(_MD("_raise_self"),&CanvasItem::_raise_self); - ObjectTypeDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback); - ObjectTypeDB::bind_method(_MD("_set_visible_"),&CanvasItem::_set_visible_); - ObjectTypeDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_); - - ObjectTypeDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state); - ObjectTypeDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state); - ObjectTypeDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect); - ObjectTypeDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate); - - ObjectTypeDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect); - ObjectTypeDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect); - //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); - - ObjectTypeDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item); - - ObjectTypeDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible); - ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden); - ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show); - ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide); - ObjectTypeDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden); - - ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update); - - ObjectTypeDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel); - ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel); - - ObjectTypeDB::bind_method(_MD("set_blend_mode","blend_mode"),&CanvasItem::set_blend_mode); - ObjectTypeDB::bind_method(_MD("get_blend_mode"),&CanvasItem::get_blend_mode); - - ObjectTypeDB::bind_method(_MD("set_light_mask","light_mask"),&CanvasItem::set_light_mask); - ObjectTypeDB::bind_method(_MD("get_light_mask"),&CanvasItem::get_light_mask); - - ObjectTypeDB::bind_method(_MD("set_opacity","opacity"),&CanvasItem::set_opacity); - ObjectTypeDB::bind_method(_MD("get_opacity"),&CanvasItem::get_opacity); - ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity); - ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity); - - ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent); - ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled); - - ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top); - ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top); - //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); - - ObjectTypeDB::bind_method(_MD("draw_line","from","to","color","width","antialiased"),&CanvasItem::draw_line,DEFVAL(1.0),DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect); - ObjectTypeDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle); - ObjectTypeDB::bind_method(_MD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1))); - ObjectTypeDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box); - ObjectTypeDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0)); - ObjectTypeDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant())); - ObjectTypeDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant())); - ObjectTypeDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1)); - ObjectTypeDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1))); - - ObjectTypeDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform); - ObjectTypeDB::bind_method(_MD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix); - 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_local_mouse_pos"),&CanvasItem::get_local_mouse_pos); - ObjectTypeDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos); - 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_material","material:CanvasItemMaterial"),&CanvasItem::set_material); - ObjectTypeDB::bind_method(_MD("get_material:CanvasItemMaterial"),&CanvasItem::get_material); - - 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_canvas_pos_local","screen_point"), + ClassDB::bind_method(_MD("_toplevel_raise_self"),&CanvasItem::_toplevel_raise_self); + ClassDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback); + + ClassDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state); + ClassDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state); + ClassDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect); + ClassDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate); + + ClassDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect); + ClassDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect); + //ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); + + ClassDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item); + + ClassDB::bind_method(_MD("set_visible"),&CanvasItem::set_visible); + ClassDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible); + ClassDB::bind_method(_MD("is_visible_in_tree"),&CanvasItem::is_visible_in_tree); + ClassDB::bind_method(_MD("show"),&CanvasItem::show); + ClassDB::bind_method(_MD("hide"),&CanvasItem::hide); + + ClassDB::bind_method(_MD("update"),&CanvasItem::update); + + ClassDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel); + ClassDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel); + + ClassDB::bind_method(_MD("set_light_mask","light_mask"),&CanvasItem::set_light_mask); + ClassDB::bind_method(_MD("get_light_mask"),&CanvasItem::get_light_mask); + + ClassDB::bind_method(_MD("set_modulate","modulate"),&CanvasItem::set_modulate); + ClassDB::bind_method(_MD("get_modulate"),&CanvasItem::get_modulate); + ClassDB::bind_method(_MD("set_self_modulate","self_modulate"),&CanvasItem::set_self_modulate); + ClassDB::bind_method(_MD("get_self_modulate"),&CanvasItem::get_self_modulate); + + ClassDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent); + ClassDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled); + + ClassDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top); + ClassDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top); + //ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); + + ClassDB::bind_method(_MD("draw_line","from","to","color","width","antialiased"),&CanvasItem::draw_line,DEFVAL(1.0),DEFVAL(false)); + ClassDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect); + ClassDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle); + ClassDB::bind_method(_MD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1))); + ClassDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false)); + ClassDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false)); + ClassDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box); + ClassDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0)); + ClassDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant())); + ClassDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant())); + ClassDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1)); + ClassDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1))); + + ClassDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform); + ClassDB::bind_method(_MD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix); + ClassDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); + ClassDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform); + ClassDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas); + ClassDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform); + ClassDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect); + ClassDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform); + ClassDB::bind_method(_MD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos); + ClassDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos); + ClassDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas); + ClassDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d); + //ClassDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport); + + ClassDB::bind_method(_MD("set_material","material:CanvasItemMaterial"),&CanvasItem::set_material); + ClassDB::bind_method(_MD("get_material:CanvasItemMaterial"),&CanvasItem::get_material); + + ClassDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material); + ClassDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material); + + ClassDB::bind_method(_MD("set_notify_local_transform","enable"),&CanvasItem::set_notify_local_transform); + ClassDB::bind_method(_MD("is_local_transform_notification_enabled"),&CanvasItem::is_local_transform_notification_enabled); + + ClassDB::bind_method(_MD("set_notify_transform","enable"),&CanvasItem::set_notify_transform); + ClassDB::bind_method(_MD("is_transform_notification_enabled"),&CanvasItem::is_transform_notification_enabled); + + ClassDB::bind_method(_MD("make_canvas_pos_local","screen_point"), &CanvasItem::make_canvas_pos_local); - ObjectTypeDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local); + ClassDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local); BIND_VMETHOD(MethodInfo("_draw")); - ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") ); - ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") ); - ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") ); - ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility - - 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_PROPERTYNO( PropertyInfo(Variant::INT,"visibility/light_mask",PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"),_SCS("get_light_mask") ); - 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") ); + ADD_GROUP("Visibility",""); + ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visible"), _SCS("set_visible"),_SCS("is_visible") ); + ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"modulate"), _SCS("set_modulate"),_SCS("get_modulate") ); + ADD_PROPERTYNO( PropertyInfo(Variant::COLOR,"self_modulate"), _SCS("set_self_modulate"),_SCS("get_self_modulate") ); + ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"show_behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER), _SCS("set_light_mask"),_SCS("get_light_mask") ); + + ADD_GROUP("Material",""); + ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") ); + ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"use_parent_material"), _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")); @@ -1105,9 +1028,9 @@ void CanvasItem::_bind_methods() { } -Matrix32 CanvasItem::get_canvas_transform() const { +Transform2D CanvasItem::get_canvas_transform() const { - ERR_FAIL_COND_V(!is_inside_tree(),Matrix32()); + ERR_FAIL_COND_V(!is_inside_tree(),Transform2D()); if (canvas_layer) return canvas_layer->get_transform(); @@ -1118,9 +1041,9 @@ Matrix32 CanvasItem::get_canvas_transform() const { } -Matrix32 CanvasItem::get_viewport_transform() const { +Transform2D CanvasItem::get_viewport_transform() const { - ERR_FAIL_COND_V(!is_inside_tree(),Matrix32()); + ERR_FAIL_COND_V(!is_inside_tree(),Transform2D()); if (canvas_layer) { @@ -1145,6 +1068,15 @@ bool CanvasItem::is_local_transform_notification_enabled() const { return notify_local_transform; } + +void CanvasItem::set_notify_transform(bool p_enable) { + notify_transform=p_enable; +} + +bool CanvasItem::is_transform_notification_enabled() const { + return notify_transform; +} + int CanvasItem::get_canvas_layer() const { if (canvas_layer) @@ -1174,22 +1106,21 @@ CanvasItem::CanvasItem() : xform_change(this) { canvas_item=VisualServer::get_singleton()->canvas_item_create(); - hidden=false; + visible=true; pending_update=false; - opacity=1; - self_opacity=1; + modulate=Color(1,1,1,1); + self_modulate=Color(1,1,1,1); toplevel=false; - pending_children_sort=false; first_draw=false; - blend_mode=BLEND_MODE_MIX; drawing=false; behind=false; - block_transform_notify=false; -// viewport=NULL; + block_transform_notify=false; + //viewport=NULL; canvas_layer=NULL; use_parent_material=false; global_invalid=true; notify_local_transform=false; + notify_transform=false; light_mask=1; C=NULL; diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 58397c1fb0..9688b873c0 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,6 +33,7 @@ #include "scene/resources/texture.h" #include "scene/main/scene_main_loop.h" #include "scene/resources/shader.h" +#include "scene/resources/material.h" class CanvasLayer; class Viewport; @@ -40,22 +41,18 @@ class Font; class StyleBox; -class CanvasItemMaterial : public Resource{ +class CanvasItemMaterial : public Material { - OBJ_TYPE(CanvasItemMaterial,Resource); - RID material; + GDCLASS(CanvasItemMaterial,Material); Ref<Shader> shader; public: - enum ShadingMode { + /*enum ShadingMode { SHADING_NORMAL, SHADING_UNSHADED, SHADING_ONLY_LIGHT, - }; + };*/ protected: - - ShadingMode shading_mode; - 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; @@ -72,20 +69,16 @@ public: void set_shader_param(const StringName& p_param,const Variant& p_value); Variant get_shader_param(const StringName& p_param) const; - void set_shading_mode(ShadingMode p_mode); - ShadingMode get_shading_mode() const; - - virtual RID get_rid() const; CanvasItemMaterial(); ~CanvasItemMaterial(); }; -VARIANT_ENUM_CAST( CanvasItemMaterial::ShadingMode ); + class CanvasItem : public Node { - OBJ_TYPE( CanvasItem, Node ); + GDCLASS( CanvasItem, Node ); public: enum BlendMode { @@ -107,47 +100,41 @@ private: CanvasLayer *canvas_layer; - float opacity; - float self_opacity; + Color modulate; + Color self_modulate; List<CanvasItem*> children_items; List<CanvasItem*>::Element *C; - BlendMode blend_mode; int light_mask; bool first_draw; - bool hidden; + bool visible; bool pending_update; bool toplevel; - bool pending_children_sort; bool drawing; bool block_transform_notify; bool behind; bool use_parent_material; bool notify_local_transform; + bool notify_transform; Ref<CanvasItemMaterial> material; - mutable Matrix32 global_transform; + mutable Transform2D global_transform; mutable bool global_invalid; - void _raise_self(); + void _toplevel_raise_self(); void _propagate_visibility_changed(bool p_visible); - void _set_visible_(bool p_visible); - bool _is_visible_() const; void _update_callback(); void _enter_canvas(); void _exit_canvas(); - void _queue_sort_children(); - void _sort_children(); - void _notify_transform(CanvasItem *p_node); void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); } @@ -185,25 +172,22 @@ public: /* VISIBILITY */ + void set_visible(bool p_visible); bool is_visible() const; - bool is_hidden() const; + bool is_visible_in_tree() const; void show(); void hide(); - void set_hidden(bool p_hidden); void update(); - virtual void set_blend_mode(BlendMode p_blend_mode); - BlendMode get_blend_mode() const; - virtual void set_light_mask(int p_light_mask); int get_light_mask() const; - void set_opacity(float p_opacity); - float get_opacity() const; + void set_modulate(const Color& p_modulate); + Color get_modulate() const; - void set_self_opacity(float p_self_opacity); - float get_self_opacity() const; + void set_self_modulate(const Color& p_self_modulate); + Color get_self_modulate() const; /* DRAWING API */ @@ -222,7 +206,7 @@ public: float draw_char(const Ref<Font>& p_font,const Point2& p_pos, const String& p_char,const String& p_next="",const Color& p_modulate=Color(1,1,1)); void draw_set_transform(const Point2& p_offset, float p_rot, const Size2& p_scale); - void draw_set_transform_matrix(const Matrix32& p_matrix); + void draw_set_transform_matrix(const Transform2D& p_matrix); /* RECT / TRANSFORM */ @@ -235,10 +219,10 @@ public: CanvasItem *get_parent_item() const; virtual Rect2 get_item_rect() const=0; - virtual Matrix32 get_transform() const=0; + virtual Transform2D get_transform() const=0; - virtual Matrix32 get_global_transform() const; - virtual Matrix32 get_global_transform_with_canvas() const; + virtual Transform2D get_global_transform() const; + virtual Transform2D get_global_transform_with_canvas() const; Rect2 get_item_and_children_rect() const; @@ -249,8 +233,8 @@ public: bool is_block_transform_notify_enabled() const; - Matrix32 get_canvas_transform() const; - Matrix32 get_viewport_transform() const; + Transform2D get_canvas_transform() const; + Transform2D get_viewport_transform() const; Rect2 get_viewport_rect() const; RID get_viewport_rid() const; RID get_canvas() const; @@ -271,6 +255,9 @@ public: void set_notify_local_transform(bool p_enable); bool is_local_transform_notification_enabled() const; + void set_notify_transform(bool p_enable); + bool is_transform_notification_enabled() const; + int get_canvas_layer() const; CanvasItem(); diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp index e4a0500123..138589651c 100644 --- a/scene/2d/canvas_modulate.cpp +++ b/scene/2d/canvas_modulate.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ void CanvasModulate::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_CANVAS) { - if (is_visible()) { + if (is_visible_in_tree()) { VS::get_singleton()->canvas_set_modulate(get_canvas(),color); add_to_group("_canvas_modulate_"+itos(get_canvas().get_id())); } @@ -42,13 +42,13 @@ void CanvasModulate::_notification(int p_what) { } else if (p_what==NOTIFICATION_EXIT_CANVAS) { - if (is_visible()) { + if (is_visible_in_tree()) { VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1)); remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id())); } } else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { - if (is_visible()) { + if (is_visible_in_tree()) { VS::get_singleton()->canvas_set_modulate(get_canvas(),color); add_to_group("_canvas_modulate_"+itos(get_canvas().get_id())); } else { @@ -62,8 +62,8 @@ void CanvasModulate::_notification(int p_what) { void CanvasModulate::_bind_methods(){ - ObjectTypeDB::bind_method(_MD("set_color","color"),&CanvasModulate::set_color); - ObjectTypeDB::bind_method(_MD("get_color"),&CanvasModulate::get_color); + ClassDB::bind_method(_MD("set_color","color"),&CanvasModulate::set_color); + ClassDB::bind_method(_MD("get_color"),&CanvasModulate::get_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color")); } @@ -83,7 +83,7 @@ Color CanvasModulate::get_color() const { String CanvasModulate::get_configuration_warning() const { - if (!is_visible() || !is_inside_tree()) + if (!is_visible_in_tree() || !is_inside_tree()) return String(); List<Node*> nodes; diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h index ed642c788d..a0bb27b1c5 100644 --- a/scene/2d/canvas_modulate.h +++ b/scene/2d/canvas_modulate.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ class CanvasModulate : public Node2D { - OBJ_TYPE(CanvasModulate,Node2D); + GDCLASS(CanvasModulate,Node2D); Color color; protected: diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index b5a6cc435f..3668963251 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -196,7 +196,7 @@ void CollisionObject2D::_mouse_enter() { if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_enter); } - emit_signal(SceneStringNames::get_singleton()->mouse_enter); + emit_signal(SceneStringNames::get_singleton()->mouse_entered); } @@ -205,14 +205,14 @@ void CollisionObject2D::_mouse_exit() { if (get_script_instance()) { get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit); } - emit_signal(SceneStringNames::get_singleton()->mouse_exit); + emit_signal(SceneStringNames::get_singleton()->mouse_exited); } void CollisionObject2D::_update_pickable() { if (!is_inside_tree()) return; - bool pickable = this->pickable && is_inside_tree() && is_visible(); + bool pickable = this->pickable && is_inside_tree() && is_visible_in_tree(); if (area) Physics2DServer::get_singleton()->area_set_pickable(rid,pickable); else @@ -221,33 +221,35 @@ void CollisionObject2D::_update_pickable() { void CollisionObject2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Matrix32())); - ObjectTypeDB::bind_method(_MD("get_shape_count"),&CollisionObject2D::get_shape_count); - ObjectTypeDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape); - ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform); - ObjectTypeDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject2D::set_shape_as_trigger); - ObjectTypeDB::bind_method(_MD("get_shape:Shape2D","shape_idx"),&CollisionObject2D::get_shape); - ObjectTypeDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject2D::get_shape_transform); - ObjectTypeDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject2D::is_shape_set_as_trigger); - ObjectTypeDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject2D::remove_shape); - 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); + ClassDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Transform2D())); + ClassDB::bind_method(_MD("get_shape_count"),&CollisionObject2D::get_shape_count); + ClassDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape); + ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform); + ClassDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject2D::set_shape_as_trigger); + ClassDB::bind_method(_MD("get_shape:Shape2D","shape_idx"),&CollisionObject2D::get_shape); + ClassDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject2D::get_shape_transform); + ClassDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject2D::is_shape_set_as_trigger); + ClassDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject2D::remove_shape); + ClassDB::bind_method(_MD("clear_shapes"),&CollisionObject2D::clear_shapes); + ClassDB::bind_method(_MD("get_rid"),&CollisionObject2D::get_rid); + + ClassDB::bind_method(_MD("set_pickable","enabled"),&CollisionObject2D::set_pickable); + ClassDB::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_SIGNAL( MethodInfo("mouse_entered")); + ADD_SIGNAL( MethodInfo("mouse_exited")); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input/pickable"),_SCS("set_pickable"),_SCS("is_pickable")); + ADD_GROUP("Pickable","input_"); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input_pickable"),_SCS("set_pickable"),_SCS("is_pickable")); + ADD_GROUP("",""); } -void CollisionObject2D::add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform) { +void CollisionObject2D::add_shape(const Ref<Shape2D>& p_shape, const Transform2D& p_transform) { ERR_FAIL_COND(p_shape.is_null()); @@ -280,10 +282,10 @@ void CollisionObject2D::set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape) else Physics2DServer::get_singleton()->body_set_shape(get_rid(),p_shape_idx,p_shape->get_rid()); -// _update_shapes(); + //_update_shapes(); } -void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_transform) { +void CollisionObject2D::set_shape_transform(int p_shape_idx, const Transform2D& p_transform) { ERR_FAIL_INDEX(p_shape_idx,shapes.size()); shapes[p_shape_idx].xform=p_transform; @@ -293,7 +295,7 @@ void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_t else Physics2DServer::get_singleton()->body_set_shape_transform(get_rid(),p_shape_idx,p_transform); -// _update_shapes(); + //_update_shapes(); } Ref<Shape2D> CollisionObject2D::get_shape(int p_shape_idx) const { @@ -302,9 +304,9 @@ Ref<Shape2D> CollisionObject2D::get_shape(int p_shape_idx) const { return shapes[p_shape_idx].shape; } -Matrix32 CollisionObject2D::get_shape_transform(int p_shape_idx) const { +Transform2D CollisionObject2D::get_shape_transform(int p_shape_idx) const { - ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Matrix32()); + ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Transform2D()); return shapes[p_shape_idx].xform; } @@ -361,6 +363,7 @@ CollisionObject2D::CollisionObject2D() { //owner= + set_notify_transform(true); } diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index fc50c5c7cd..429b4fafe6 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,14 +34,14 @@ class CollisionObject2D : public Node2D { - OBJ_TYPE( CollisionObject2D, Node2D ); + GDCLASS( CollisionObject2D, Node2D ); bool area; RID rid; bool pickable; struct ShapeData { - Matrix32 xform; + Transform2D xform; Ref<Shape2D> shape; bool trigger; @@ -78,12 +78,12 @@ public: - void add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform=Matrix32()); + void add_shape(const Ref<Shape2D>& p_shape, const Transform2D& p_transform=Transform2D()); int get_shape_count() const; void set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape); - void set_shape_transform(int p_shape_idx, const Matrix32& p_transform); + void set_shape_transform(int p_shape_idx, const Transform2D& p_transform); Ref<Shape2D> get_shape(int p_shape_idx) const; - Matrix32 get_shape_transform(int p_shape_idx) const; + Transform2D get_shape_transform(int p_shape_idx) const; void set_shape_as_trigger(int p_shape_idx, bool p_trigger); bool is_shape_set_as_trigger(int p_shape_idx) const; void remove_shape(int p_shape_idx); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 544f0e2088..04f096f229 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -68,16 +68,16 @@ void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) { Ref<ConcavePolygonShape2D> concave = memnew( ConcavePolygonShape2D ); - DVector<Vector2> segments; + PoolVector<Vector2> segments; segments.resize(polygon.size()*2); - DVector<Vector2>::Write w=segments.write(); + PoolVector<Vector2>::Write w=segments.write(); for(int i=0;i<polygon.size();i++) { w[(i<<1)+0]=polygon[i]; w[(i<<1)+1]=polygon[(i+1)%polygon.size()]; } - w=DVector<Vector2>::Write(); + w=PoolVector<Vector2>::Write(); concave->set_segments(segments); co->add_shape(concave,get_transform()); @@ -313,24 +313,24 @@ String CollisionPolygon2D::get_configuration_warning() const { void CollisionPolygon2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon2D::_add_to_collision_object); - ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon); - ObjectTypeDB::bind_method(_MD("get_polygon"),&CollisionPolygon2D::get_polygon); + ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon2D::_add_to_collision_object); + ClassDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon); + ClassDB::bind_method(_MD("get_polygon"),&CollisionPolygon2D::get_polygon); - ObjectTypeDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode); - ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode); + ClassDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode); + ClassDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode); - ObjectTypeDB::bind_method(_MD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger); - ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionPolygon2D::is_trigger); + ClassDB::bind_method(_MD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger); + ClassDB::bind_method(_MD("is_trigger"),&CollisionPolygon2D::is_trigger); - ObjectTypeDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range); - ObjectTypeDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon2D::_get_shape_range); + ClassDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range); + ClassDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon2D::_get_shape_range); - ObjectTypeDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon2D::get_collision_object_first_shape); - ObjectTypeDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape); + ClassDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon2D::get_collision_object_first_shape); + ClassDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape); ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Segments"),_SCS("set_build_mode"),_SCS("get_build_mode")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger")); diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index 9c0e4e0c01..dda850b41d 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -36,7 +36,7 @@ class CollisionPolygon2D : public Node2D { - OBJ_TYPE(CollisionPolygon2D,Node2D); + GDCLASS(CollisionPolygon2D,Node2D); public: enum BuildMode { diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index c737cf0faf..a92065d6fb 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -217,17 +217,17 @@ String CollisionShape2D::get_configuration_warning() const { void CollisionShape2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_shape","shape"),&CollisionShape2D::set_shape); - ObjectTypeDB::bind_method(_MD("get_shape"),&CollisionShape2D::get_shape); - ObjectTypeDB::bind_method(_MD("_shape_changed"),&CollisionShape2D::_shape_changed); - ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape2D::_add_to_collision_object); - ObjectTypeDB::bind_method(_MD("set_trigger","enable"),&CollisionShape2D::set_trigger); - ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionShape2D::is_trigger); + ClassDB::bind_method(_MD("set_shape","shape"),&CollisionShape2D::set_shape); + ClassDB::bind_method(_MD("get_shape"),&CollisionShape2D::get_shape); + ClassDB::bind_method(_MD("_shape_changed"),&CollisionShape2D::_shape_changed); + ClassDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape2D::_add_to_collision_object); + ClassDB::bind_method(_MD("set_trigger","enable"),&CollisionShape2D::set_trigger); + ClassDB::bind_method(_MD("is_trigger"),&CollisionShape2D::is_trigger); - ObjectTypeDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape2D::_set_update_shape_index); - ObjectTypeDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape2D::_get_update_shape_index); + ClassDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape2D::_set_update_shape_index); + ClassDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape2D::_get_update_shape_index); - ObjectTypeDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape2D::get_collision_object_shape_index); + ClassDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape2D::get_collision_object_shape_index); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),_SCS("set_shape"),_SCS("get_shape")); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger")); diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h index 6f3f17d412..b5cc789416 100644 --- a/scene/2d/collision_shape_2d.h +++ b/scene/2d/collision_shape_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class CollisionShape2D : public Node2D { - OBJ_TYPE(CollisionShape2D,Node2D); + GDCLASS(CollisionShape2D,Node2D); Ref<Shape2D> shape; Rect2 rect; bool trigger; diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 053fc2c9c2..987672df38 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -128,22 +128,22 @@ bool Joint2D::get_exclude_nodes_from_collision() const{ void Joint2D::_bind_methods() { - ObjectTypeDB::bind_method( _MD("set_node_a","node"), &Joint2D::set_node_a ); - ObjectTypeDB::bind_method( _MD("get_node_a"), &Joint2D::get_node_a ); + ClassDB::bind_method( _MD("set_node_a","node"), &Joint2D::set_node_a ); + ClassDB::bind_method( _MD("get_node_a"), &Joint2D::get_node_a ); - ObjectTypeDB::bind_method( _MD("set_node_b","node"), &Joint2D::set_node_b ); - ObjectTypeDB::bind_method( _MD("get_node_b"), &Joint2D::get_node_b ); + ClassDB::bind_method( _MD("set_node_b","node"), &Joint2D::set_node_b ); + ClassDB::bind_method( _MD("get_node_b"), &Joint2D::get_node_b ); - ObjectTypeDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias ); - ObjectTypeDB::bind_method( _MD("get_bias"), &Joint2D::get_bias ); + ClassDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias ); + ClassDB::bind_method( _MD("get_bias"), &Joint2D::get_bias ); - ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision ); - ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision ); + ClassDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision ); + ClassDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision ); ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), _SCS("set_node_a"),_SCS("get_node_a") ); ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), _SCS("set_node_b"),_SCS("get_node_b") ); - ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias/bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") ); + ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") ); + ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disable_collision"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") ); } @@ -225,8 +225,8 @@ real_t PinJoint2D::get_softness() const { void PinJoint2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_softness","softness"), &PinJoint2D::set_softness); - ObjectTypeDB::bind_method(_MD("get_softness"), &PinJoint2D::get_softness); + ClassDB::bind_method(_MD("set_softness","softness"), &PinJoint2D::set_softness); + ClassDB::bind_method(_MD("get_softness"), &PinJoint2D::get_softness); ADD_PROPERTY( PropertyInfo( Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE,"0.00,16,0.01"), _SCS("set_softness"), _SCS("get_softness")); } @@ -283,7 +283,7 @@ RID GrooveJoint2D::_configure_joint(){ else Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid()); - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Vector2 groove_A1 = gt.get_origin(); Vector2 groove_A2 = gt.xform( Vector2(0,length) ); Vector2 anchor_B = gt.xform( Vector2(0,initial_offset) ); @@ -321,10 +321,10 @@ real_t GrooveJoint2D::get_initial_offset() const { void GrooveJoint2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_length","length"),&GrooveJoint2D::set_length); - ObjectTypeDB::bind_method(_MD("get_length"),&GrooveJoint2D::get_length); - ObjectTypeDB::bind_method(_MD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset); - ObjectTypeDB::bind_method(_MD("get_initial_offset"),&GrooveJoint2D::get_initial_offset); + ClassDB::bind_method(_MD("set_length","length"),&GrooveJoint2D::set_length); + ClassDB::bind_method(_MD("get_length"),&GrooveJoint2D::get_length); + ClassDB::bind_method(_MD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset); + ClassDB::bind_method(_MD("get_initial_offset"),&GrooveJoint2D::get_initial_offset); ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length")); ADD_PROPERTY( PropertyInfo( Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_initial_offset"),_SCS("get_initial_offset")); @@ -384,7 +384,7 @@ RID DampedSpringJoint2D::_configure_joint(){ else Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid()); - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Vector2 anchor_A = gt.get_origin(); Vector2 anchor_B = gt.xform( Vector2(0,length) ); @@ -453,14 +453,14 @@ real_t DampedSpringJoint2D::get_damping() const { void DampedSpringJoint2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_length","length"),&DampedSpringJoint2D::set_length); - ObjectTypeDB::bind_method(_MD("get_length"),&DampedSpringJoint2D::get_length); - ObjectTypeDB::bind_method(_MD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length); - ObjectTypeDB::bind_method(_MD("get_rest_length"),&DampedSpringJoint2D::get_rest_length); - ObjectTypeDB::bind_method(_MD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness); - ObjectTypeDB::bind_method(_MD("get_stiffness"),&DampedSpringJoint2D::get_stiffness); - ObjectTypeDB::bind_method(_MD("set_damping","damping"),&DampedSpringJoint2D::set_damping); - ObjectTypeDB::bind_method(_MD("get_damping"),&DampedSpringJoint2D::get_damping); + ClassDB::bind_method(_MD("set_length","length"),&DampedSpringJoint2D::set_length); + ClassDB::bind_method(_MD("get_length"),&DampedSpringJoint2D::get_length); + ClassDB::bind_method(_MD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length); + ClassDB::bind_method(_MD("get_rest_length"),&DampedSpringJoint2D::get_rest_length); + ClassDB::bind_method(_MD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness); + ClassDB::bind_method(_MD("get_stiffness"),&DampedSpringJoint2D::get_stiffness); + ClassDB::bind_method(_MD("set_damping","damping"),&DampedSpringJoint2D::set_damping); + ClassDB::bind_method(_MD("get_damping"),&DampedSpringJoint2D::get_damping); ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length")); ADD_PROPERTY( PropertyInfo( Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE,"0,65535,1"), _SCS("set_rest_length"),_SCS("get_rest_length")); diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index 52ffd86e7c..3b3eec6bd6 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class Joint2D : public Node2D { - OBJ_TYPE(Joint2D,Node2D); + GDCLASS(Joint2D,Node2D); RID joint; @@ -75,7 +75,7 @@ public: class PinJoint2D : public Joint2D { - OBJ_TYPE(PinJoint2D,Joint2D); + GDCLASS(PinJoint2D,Joint2D); real_t softness; @@ -94,7 +94,7 @@ public: class GrooveJoint2D : public Joint2D { - OBJ_TYPE(GrooveJoint2D,Joint2D); + GDCLASS(GrooveJoint2D,Joint2D); real_t length; real_t initial_offset; @@ -117,7 +117,7 @@ public: class DampedSpringJoint2D : public Joint2D { - OBJ_TYPE(DampedSpringJoint2D,Joint2D); + GDCLASS(DampedSpringJoint2D,Joint2D); real_t stiffness; real_t damping; diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 3e548a24b0..2935f6b9f7 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -83,7 +83,7 @@ void Light2D::_update_light_visibility() { } #endif - VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible() && editor_ok); + VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible_in_tree() && editor_ok); } void Light2D::set_enabled( bool p_enabled) { @@ -235,26 +235,26 @@ int Light2D::get_layer_range_max() const { return layer_max; } -void Light2D::set_item_mask( int p_mask) { +void Light2D::set_item_cull_mask( int p_mask) { item_mask=p_mask; - VS::get_singleton()->canvas_light_set_item_mask(canvas_light,item_mask); + VS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light,item_mask); } -int Light2D::get_item_mask() const { +int Light2D::get_item_cull_mask() const { return item_mask; } -void Light2D::set_item_shadow_mask( int p_mask) { +void Light2D::set_item_shadow_cull_mask( int p_mask) { item_shadow_mask=p_mask; - VS::get_singleton()->canvas_light_set_item_shadow_mask(canvas_light,item_shadow_mask); + VS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light,item_shadow_mask); } -int Light2D::get_item_shadow_mask() const { +int Light2D::get_item_shadow_cull_mask() const { return item_shadow_mask; } @@ -292,17 +292,30 @@ int Light2D::get_shadow_buffer_size() const { return shadow_buffer_size; } -void Light2D::set_shadow_esm_multiplier( float p_multiplier) { +void Light2D::set_shadow_gradient_length( float p_multiplier) { - shadow_esm_multiplier=p_multiplier; - VS::get_singleton()->canvas_light_set_shadow_esm_multiplier(canvas_light,p_multiplier); + shadow_gradient_length=p_multiplier; + VS::get_singleton()->canvas_light_set_shadow_gradient_length(canvas_light,p_multiplier); } -float Light2D::get_shadow_esm_multiplier() const{ +float Light2D::get_shadow_gradient_length() const{ - return shadow_esm_multiplier; + return shadow_gradient_length; } + +void Light2D::set_shadow_filter( ShadowFilter p_filter) { + shadow_filter=p_filter; + VS::get_singleton()->canvas_light_set_shadow_filter(canvas_light,VS::CanvasLightShadowFilter(p_filter )); +} + +Light2D::ShadowFilter Light2D::get_shadow_filter() const { + + return shadow_filter; +} + + + void Light2D::set_shadow_color( const Color& p_shadow_color) { shadow_color=p_shadow_color; VS::get_singleton()->canvas_light_set_shadow_color(canvas_light,shadow_color); @@ -352,64 +365,67 @@ String Light2D::get_configuration_warning() const { void Light2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled); - ObjectTypeDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled); + ClassDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled); + ClassDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled); + + ClassDB::bind_method(_MD("set_editor_only","editor_only"), &Light2D::set_editor_only ); + ClassDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only ); - ObjectTypeDB::bind_method(_MD("set_editor_only","editor_only"), &Light2D::set_editor_only ); - ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only ); + ClassDB::bind_method(_MD("set_texture","texture"),&Light2D::set_texture); + ClassDB::bind_method(_MD("get_texture"),&Light2D::get_texture); - ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Light2D::set_texture); - ObjectTypeDB::bind_method(_MD("get_texture"),&Light2D::get_texture); + ClassDB::bind_method(_MD("set_texture_offset","texture_offset"),&Light2D::set_texture_offset); + ClassDB::bind_method(_MD("get_texture_offset"),&Light2D::get_texture_offset); - ObjectTypeDB::bind_method(_MD("set_texture_offset","texture_offset"),&Light2D::set_texture_offset); - ObjectTypeDB::bind_method(_MD("get_texture_offset"),&Light2D::get_texture_offset); + ClassDB::bind_method(_MD("set_color","color"),&Light2D::set_color); + ClassDB::bind_method(_MD("get_color"),&Light2D::get_color); - ObjectTypeDB::bind_method(_MD("set_color","color"),&Light2D::set_color); - ObjectTypeDB::bind_method(_MD("get_color"),&Light2D::get_color); + ClassDB::bind_method(_MD("set_height","height"),&Light2D::set_height); + ClassDB::bind_method(_MD("get_height"),&Light2D::get_height); - ObjectTypeDB::bind_method(_MD("set_height","height"),&Light2D::set_height); - ObjectTypeDB::bind_method(_MD("get_height"),&Light2D::get_height); + ClassDB::bind_method(_MD("set_energy","energy"),&Light2D::set_energy); + ClassDB::bind_method(_MD("get_energy"),&Light2D::get_energy); - ObjectTypeDB::bind_method(_MD("set_energy","energy"),&Light2D::set_energy); - ObjectTypeDB::bind_method(_MD("get_energy"),&Light2D::get_energy); + ClassDB::bind_method(_MD("set_texture_scale","texture_scale"),&Light2D::set_texture_scale); + ClassDB::bind_method(_MD("get_texture_scale"),&Light2D::get_texture_scale); - ObjectTypeDB::bind_method(_MD("set_texture_scale","texture_scale"),&Light2D::set_texture_scale); - ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Light2D::get_texture_scale); + ClassDB::bind_method(_MD("set_z_range_min","z"),&Light2D::set_z_range_min); + ClassDB::bind_method(_MD("get_z_range_min"),&Light2D::get_z_range_min); - 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); + ClassDB::bind_method(_MD("set_z_range_max","z"),&Light2D::set_z_range_max); + ClassDB::bind_method(_MD("get_z_range_max"),&Light2D::get_z_range_max); - ObjectTypeDB::bind_method(_MD("set_z_range_max","z"),&Light2D::set_z_range_max); - ObjectTypeDB::bind_method(_MD("get_z_range_max"),&Light2D::get_z_range_max); + ClassDB::bind_method(_MD("set_layer_range_min","layer"),&Light2D::set_layer_range_min); + ClassDB::bind_method(_MD("get_layer_range_min"),&Light2D::get_layer_range_min); - ObjectTypeDB::bind_method(_MD("set_layer_range_min","layer"),&Light2D::set_layer_range_min); - ObjectTypeDB::bind_method(_MD("get_layer_range_min"),&Light2D::get_layer_range_min); + ClassDB::bind_method(_MD("set_layer_range_max","layer"),&Light2D::set_layer_range_max); + ClassDB::bind_method(_MD("get_layer_range_max"),&Light2D::get_layer_range_max); - ObjectTypeDB::bind_method(_MD("set_layer_range_max","layer"),&Light2D::set_layer_range_max); - ObjectTypeDB::bind_method(_MD("get_layer_range_max"),&Light2D::get_layer_range_max); + ClassDB::bind_method(_MD("set_item_cull_mask","item_cull_mask"),&Light2D::set_item_cull_mask); + ClassDB::bind_method(_MD("get_item_cull_mask"),&Light2D::get_item_cull_mask); - ObjectTypeDB::bind_method(_MD("set_item_mask","item_mask"),&Light2D::set_item_mask); - ObjectTypeDB::bind_method(_MD("get_item_mask"),&Light2D::get_item_mask); + ClassDB::bind_method(_MD("set_item_shadow_cull_mask","item_shadow_cull_mask"),&Light2D::set_item_shadow_cull_mask); + ClassDB::bind_method(_MD("get_item_shadow_cull_mask"),&Light2D::get_item_shadow_cull_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); + ClassDB::bind_method(_MD("set_mode","mode"),&Light2D::set_mode); + ClassDB::bind_method(_MD("get_mode"),&Light2D::get_mode); - ObjectTypeDB::bind_method(_MD("set_mode","mode"),&Light2D::set_mode); - ObjectTypeDB::bind_method(_MD("get_mode"),&Light2D::get_mode); + ClassDB::bind_method(_MD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled); + ClassDB::bind_method(_MD("is_shadow_enabled"),&Light2D::is_shadow_enabled); - ObjectTypeDB::bind_method(_MD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled); - ObjectTypeDB::bind_method(_MD("is_shadow_enabled"),&Light2D::is_shadow_enabled); + ClassDB::bind_method(_MD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size); + ClassDB::bind_method(_MD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size); - 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); + ClassDB::bind_method(_MD("set_shadow_gradient_length","multiplier"),&Light2D::set_shadow_gradient_length); + ClassDB::bind_method(_MD("get_shadow_gradient_length"),&Light2D::get_shadow_gradient_length); - 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); + ClassDB::bind_method(_MD("set_shadow_filter","filter"),&Light2D::set_shadow_filter); + ClassDB::bind_method(_MD("get_shadow_filter"),&Light2D::get_shadow_filter); - ObjectTypeDB::bind_method(_MD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color); - ObjectTypeDB::bind_method(_MD("get_shadow_color"),&Light2D::get_shadow_color); + ClassDB::bind_method(_MD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color); + ClassDB::bind_method(_MD("get_shadow_color"),&Light2D::get_shadow_color); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled")); @@ -420,17 +436,21 @@ void Light2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color")); ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0.01,100,0.01"),_SCS("set_energy"),_SCS("get_energy")); ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min")); - 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::COLOR,"shadow/color"),_SCS("set_shadow_color"),_SCS("get_shadow_color")); - 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")); + ADD_GROUP("Range","range_"); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"range_height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"range_z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"range_layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min")); + 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_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_item_cull_mask"),_SCS("get_item_cull_mask")); + + ADD_GROUP("Shadow","shadow_"); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow_enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled")); + ADD_PROPERTY( PropertyInfo(Variant::COLOR,"shadow_color"),_SCS("set_shadow_color"),_SCS("get_shadow_color")); + 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_gradient_length",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_gradient_length"),_SCS("get_shadow_gradient_length")); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow_filter",PROPERTY_HINT_ENUM,"None,PCF3,PCF5,PCF9,PCF13"),_SCS("set_shadow_filter"),_SCS("get_shadow_filter")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow_item_cull_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_item_shadow_cull_mask"),_SCS("get_item_shadow_cull_mask")); BIND_CONSTANT( MODE_ADD ); BIND_CONSTANT( MODE_SUB ); @@ -457,10 +477,12 @@ Light2D::Light2D() { item_shadow_mask=1; mode=MODE_ADD; shadow_buffer_size=2048; - shadow_esm_multiplier=80; + shadow_gradient_length=0; energy=1.0; shadow_color=Color(0,0,0,0); + shadow_filter=SHADOW_FILTER_NONE; + set_notify_transform(true); } Light2D::~Light2D() { diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 57c89b15e7..2bdcca5d01 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ class Light2D : public Node2D { - OBJ_TYPE(Light2D,Node2D); + GDCLASS(Light2D,Node2D); public: enum Mode { MODE_ADD, @@ -42,6 +42,14 @@ public: MODE_MASK, }; + enum ShadowFilter { + SHADOW_FILTER_NONE, + SHADOW_FILTER_PCF3, + SHADOW_FILTER_PCF5, + SHADOW_FILTER_PCF9, + SHADOW_FILTER_PCF13, + }; + private: RID canvas_light; bool enabled; @@ -59,10 +67,12 @@ private: int item_mask; int item_shadow_mask; int shadow_buffer_size; - float shadow_esm_multiplier; + float shadow_gradient_length; Mode mode; Ref<Texture> texture; Vector2 texture_offset; + ShadowFilter shadow_filter; + void _update_light_visibility(); protected: @@ -112,11 +122,11 @@ public: void set_layer_range_max( int p_max_layer); int get_layer_range_max() const; - void set_item_mask( int p_mask); - int get_item_mask() const; + void set_item_cull_mask( int p_mask); + int get_item_cull_mask() const; - void set_item_shadow_mask( int p_mask); - int get_item_shadow_mask() const; + void set_item_shadow_cull_mask( int p_mask); + int get_item_shadow_cull_mask() const; void set_mode( Mode p_mode ); Mode get_mode() const; @@ -127,8 +137,11 @@ public: 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; + void set_shadow_gradient_length( float p_multiplier); + float get_shadow_gradient_length() const; + + void set_shadow_filter( ShadowFilter p_filter); + ShadowFilter get_shadow_filter() const; void set_shadow_color( const Color& p_shadow_color); Color get_shadow_color() const; @@ -143,5 +156,7 @@ public: }; VARIANT_ENUM_CAST(Light2D::Mode); +VARIANT_ENUM_CAST(Light2D::ShadowFilter); + #endif // LIGHT_2D_H diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 58c3e2191e..77c9b8184a 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -29,14 +29,14 @@ #include "light_occluder_2d.h" -void OccluderPolygon2D::set_polygon(const DVector<Vector2>& p_polygon) { +void OccluderPolygon2D::set_polygon(const PoolVector<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{ +PoolVector<Vector2> OccluderPolygon2D::get_polygon() const{ return polygon; } @@ -78,18 +78,18 @@ RID OccluderPolygon2D::get_rid() const { void OccluderPolygon2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_closed","closed"),&OccluderPolygon2D::set_closed); - ObjectTypeDB::bind_method(_MD("is_closed"),&OccluderPolygon2D::is_closed); + ClassDB::bind_method(_MD("set_closed","closed"),&OccluderPolygon2D::set_closed); + ClassDB::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); + ClassDB::bind_method(_MD("set_cull_mode","cull_mode"),&OccluderPolygon2D::set_cull_mode); + ClassDB::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); + ClassDB::bind_method(_MD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon); + ClassDB::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")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); BIND_CONSTANT(CULL_DISABLED); BIND_CONSTANT(CULL_CLOCKWISE); @@ -123,7 +123,7 @@ void LightOccluder2D::_notification(int p_what) { VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,get_canvas()); VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform()); - VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible()); + VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree()); } if (p_what==NOTIFICATION_TRANSFORM_CHANGED) { @@ -132,7 +132,7 @@ void LightOccluder2D::_notification(int p_what) { } if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { - VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible()); + VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible_in_tree()); } if (p_what==NOTIFICATION_DRAW) { @@ -141,7 +141,7 @@ void LightOccluder2D::_notification(int p_what) { if (occluder_polygon.is_valid()) { - DVector<Vector2> poly = occluder_polygon->get_polygon(); + PoolVector<Vector2> poly = occluder_polygon->get_polygon(); if (poly.size()) { if (occluder_polygon->is_closed()) { @@ -151,7 +151,7 @@ void LightOccluder2D::_notification(int p_what) { } else { int ps=poly.size(); - DVector<Vector2>::Read r = poly.read(); + PoolVector<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); @@ -224,24 +224,25 @@ String LightOccluder2D::get_configuration_warning() const { 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); + ClassDB::bind_method(_MD("set_occluder_polygon","polygon:OccluderPolygon2D"),&LightOccluder2D::set_occluder_polygon); + ClassDB::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); + ClassDB::bind_method(_MD("set_occluder_light_mask","mask"),&LightOccluder2D::set_occluder_light_mask); + ClassDB::bind_method(_MD("get_occluder_light_mask"),&LightOccluder2D::get_occluder_light_mask); #ifdef DEBUG_ENABLED - ObjectTypeDB::bind_method("_poly_changed",&LightOccluder2D::_poly_changed); + ClassDB::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")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask")); } LightOccluder2D::LightOccluder2D() { occluder=VS::get_singleton()->canvas_light_occluder_create(); mask=1; + set_notify_transform(true); } LightOccluder2D::~LightOccluder2D() { diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h index 69ed860a84..777785cd1d 100644 --- a/scene/2d/light_occluder_2d.h +++ b/scene/2d/light_occluder_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ class OccluderPolygon2D : public Resource { - OBJ_TYPE(OccluderPolygon2D,Resource); + GDCLASS(OccluderPolygon2D,Resource); public: enum CullMode { @@ -45,7 +45,7 @@ private: RID occ_polygon; - DVector<Vector2> polygon; + PoolVector<Vector2> polygon; bool closed; CullMode cull; @@ -54,8 +54,8 @@ protected: static void _bind_methods(); public: - void set_polygon(const DVector<Vector2>& p_polygon); - DVector<Vector2> get_polygon() const; + void set_polygon(const PoolVector<Vector2>& p_polygon); + PoolVector<Vector2> get_polygon() const; void set_closed(bool p_closed); bool is_closed() const; @@ -72,7 +72,7 @@ public: VARIANT_ENUM_CAST(OccluderPolygon2D::CullMode); class LightOccluder2D : public Node2D { - OBJ_TYPE(LightOccluder2D,Node2D); + GDCLASS(LightOccluder2D,Node2D); RID occluder; bool enabled; diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 82c1327a8f..ec1109b41b 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -36,12 +36,12 @@ void Navigation2D::_navpoly_link(int p_id) { NavMesh &nm=navpoly_map[p_id]; ERR_FAIL_COND(nm.linked); - DVector<Vector2> vertices=nm.navpoly->get_vertices(); + PoolVector<Vector2> vertices=nm.navpoly->get_vertices(); int len = vertices.size(); if (len==0) return; - DVector<Vector2>::Read r=vertices.read(); + PoolVector<Vector2>::Read r=vertices.read(); for(int i=0;i<nm.navpoly->get_polygon_count();i++) { @@ -127,7 +127,7 @@ void Navigation2D::_navpoly_link(int p_id) { C->get().B=&p; C->get().B_edge=j; C->get().A->edges[C->get().A_edge].C=&p; - C->get().A->edges[C->get().A_edge].C_edge=j;; + C->get().A->edges[C->get().A_edge].C_edge=j; p.edges[j].C=C->get().A; p.edges[j].C_edge=C->get().A_edge; //connection successful. @@ -212,7 +212,7 @@ void Navigation2D::_navpoly_unlink(int p_id) { } -int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Matrix32& p_xform, Object *p_owner) { +int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Transform2D& p_xform, Object *p_owner) { int id = last_id++; NavMesh nm; @@ -227,7 +227,7 @@ int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Mat return id; } -void Navigation2D::navpoly_set_transform(int p_id, const Matrix32& p_xform){ +void Navigation2D::navpoly_set_transform(int p_id, const Transform2D& p_xform){ ERR_FAIL_COND(!navpoly_map.has(p_id)); NavMesh &nm=navpoly_map[p_id]; @@ -432,7 +432,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect while(!found_route) { if (open_list.size()==0) { - // print_line("NOU OPEN LIST"); + //print_line("NOU OPEN LIST"); break; } //check open list @@ -679,7 +679,7 @@ debug path path.push_back(begin_point); - path.invert();; + path.invert(); } return path; @@ -804,13 +804,13 @@ Object* Navigation2D::get_closest_point_owner(const Vector2& p_point) { void Navigation2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("navpoly_create","mesh:NavigationPolygon","xform","owner"),&Navigation2D::navpoly_create,DEFVAL(Variant())); - ObjectTypeDB::bind_method(_MD("navpoly_set_transform","id","xform"),&Navigation2D::navpoly_set_transform); - ObjectTypeDB::bind_method(_MD("navpoly_remove","id"),&Navigation2D::navpoly_remove); + ClassDB::bind_method(_MD("navpoly_create","mesh:NavigationPolygon","xform","owner"),&Navigation2D::navpoly_create,DEFVAL(Variant())); + ClassDB::bind_method(_MD("navpoly_set_transform","id","xform"),&Navigation2D::navpoly_set_transform); + ClassDB::bind_method(_MD("navpoly_remove","id"),&Navigation2D::navpoly_remove); - ObjectTypeDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation2D::get_simple_path,DEFVAL(true)); - ObjectTypeDB::bind_method(_MD("get_closest_point","to_point"),&Navigation2D::get_closest_point); - ObjectTypeDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation2D::get_closest_point_owner); + ClassDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation2D::get_simple_path,DEFVAL(true)); + ClassDB::bind_method(_MD("get_closest_point","to_point"),&Navigation2D::get_closest_point); + ClassDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation2D::get_closest_point_owner); } diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h index 415470295b..63827ebb6d 100644 --- a/scene/2d/navigation2d.h +++ b/scene/2d/navigation2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class Navigation2D : public Node2D { - OBJ_TYPE( Navigation2D, Node2D); + GDCLASS( Navigation2D, Node2D); union Point { @@ -119,7 +119,7 @@ class Navigation2D : public Node2D { struct NavMesh { Object *owner; - Matrix32 xform; + Transform2D xform; bool linked; Ref<NavigationPolygon> navpoly; List<Polygon> polygons; @@ -164,8 +164,8 @@ protected: public: //API should be as dynamic as possible - int navpoly_create(const Ref<NavigationPolygon>& p_mesh,const Matrix32& p_xform,Object* p_owner=NULL); - void navpoly_set_transform(int p_id, const Matrix32& p_xform); + int navpoly_create(const Ref<NavigationPolygon>& p_mesh,const Transform2D& p_xform,Object* p_owner=NULL); + void navpoly_set_transform(int p_id, const Transform2D& p_xform); void navpoly_remove(int p_id); Vector<Vector2> get_simple_path(const Vector2& p_start, const Vector2& p_end,bool p_optimize=true); diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 95f71104d0..88d6a90e81 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -31,12 +31,12 @@ #include "triangulator.h" #include "core_string_names.h" -void NavigationPolygon::set_vertices(const DVector<Vector2>& p_vertices) { +void NavigationPolygon::set_vertices(const PoolVector<Vector2>& p_vertices) { vertices=p_vertices; } -DVector<Vector2> NavigationPolygon::get_vertices() const{ +PoolVector<Vector2> NavigationPolygon::get_vertices() const{ return vertices; } @@ -89,7 +89,7 @@ void NavigationPolygon::add_polygon(const Vector<int>& p_polygon){ } -void NavigationPolygon::add_outline_at_index(const DVector<Vector2>& p_outline,int p_index) { +void NavigationPolygon::add_outline_at_index(const PoolVector<Vector2>& p_outline,int p_index) { outlines.insert(p_index,p_outline); } @@ -108,7 +108,7 @@ void NavigationPolygon::clear_polygons(){ polygons.clear(); } -void NavigationPolygon::add_outline(const DVector<Vector2>& p_outline) { +void NavigationPolygon::add_outline(const PoolVector<Vector2>& p_outline) { outlines.push_back(p_outline); } @@ -118,7 +118,7 @@ int NavigationPolygon::get_outline_count() const{ return outlines.size(); } -void NavigationPolygon::set_outline(int p_idx,const DVector<Vector2>& p_outline) { +void NavigationPolygon::set_outline(int p_idx,const PoolVector<Vector2>& p_outline) { ERR_FAIL_INDEX(p_idx,outlines.size()); outlines[p_idx]=p_outline; } @@ -130,14 +130,14 @@ void NavigationPolygon::remove_outline(int p_idx) { } -DVector<Vector2> NavigationPolygon::get_outline(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx,outlines.size(),DVector<Vector2>()); +PoolVector<Vector2> NavigationPolygon::get_outline(int p_idx) const { + ERR_FAIL_INDEX_V(p_idx,outlines.size(),PoolVector<Vector2>()); return outlines[p_idx]; } void NavigationPolygon::clear_outlines(){ - outlines.clear();; + outlines.clear(); } void NavigationPolygon::make_polygons_from_outlines(){ @@ -147,11 +147,11 @@ void NavigationPolygon::make_polygons_from_outlines(){ for(int i=0;i<outlines.size();i++) { - DVector<Vector2> ol = outlines[i]; + PoolVector<Vector2> ol = outlines[i]; int olsize = ol.size(); if (olsize<3) continue; - DVector<Vector2>::Read r=ol.read(); + PoolVector<Vector2>::Read r=ol.read(); for(int j=0;j<olsize;j++) { outside_point.x = MAX( r[j].x, outside_point.x ); outside_point.y = MAX( r[j].y, outside_point.y ); @@ -165,11 +165,11 @@ void NavigationPolygon::make_polygons_from_outlines(){ for(int i=0;i<outlines.size();i++) { - DVector<Vector2> ol = outlines[i]; + PoolVector<Vector2> ol = outlines[i]; int olsize = ol.size(); if (olsize<3) continue; - DVector<Vector2>::Read r=ol.read(); + PoolVector<Vector2>::Read r=ol.read(); int interscount=0; //test if this is an outer outline @@ -178,11 +178,11 @@ void NavigationPolygon::make_polygons_from_outlines(){ if (i==k) continue; //no self intersect - DVector<Vector2> ol2 = outlines[k]; + PoolVector<Vector2> ol2 = outlines[k]; int olsize2 = ol2.size(); if (olsize2<3) continue; - DVector<Vector2>::Read r2=ol2.read(); + PoolVector<Vector2>::Read r2=ol2.read(); for(int l=0;l<olsize2;l++) { @@ -247,30 +247,30 @@ void NavigationPolygon::make_polygons_from_outlines(){ void NavigationPolygon::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_vertices","vertices"),&NavigationPolygon::set_vertices); - ObjectTypeDB::bind_method(_MD("get_vertices"),&NavigationPolygon::get_vertices); + ClassDB::bind_method(_MD("set_vertices","vertices"),&NavigationPolygon::set_vertices); + ClassDB::bind_method(_MD("get_vertices"),&NavigationPolygon::get_vertices); - ObjectTypeDB::bind_method(_MD("add_polygon","polygon"),&NavigationPolygon::add_polygon); - ObjectTypeDB::bind_method(_MD("get_polygon_count"),&NavigationPolygon::get_polygon_count); - ObjectTypeDB::bind_method(_MD("get_polygon","idx"),&NavigationPolygon::get_polygon); - ObjectTypeDB::bind_method(_MD("clear_polygons"),&NavigationPolygon::clear_polygons); + ClassDB::bind_method(_MD("add_polygon","polygon"),&NavigationPolygon::add_polygon); + ClassDB::bind_method(_MD("get_polygon_count"),&NavigationPolygon::get_polygon_count); + ClassDB::bind_method(_MD("get_polygon","idx"),&NavigationPolygon::get_polygon); + ClassDB::bind_method(_MD("clear_polygons"),&NavigationPolygon::clear_polygons); - ObjectTypeDB::bind_method(_MD("add_outline","outline"),&NavigationPolygon::add_outline); - ObjectTypeDB::bind_method(_MD("add_outline_at_index","outline","index"),&NavigationPolygon::add_outline_at_index); - ObjectTypeDB::bind_method(_MD("get_outline_count"),&NavigationPolygon::get_outline_count); - ObjectTypeDB::bind_method(_MD("set_outline","idx","outline"),&NavigationPolygon::set_outline); - ObjectTypeDB::bind_method(_MD("get_outline","idx"),&NavigationPolygon::get_outline); - ObjectTypeDB::bind_method(_MD("remove_outline","idx"),&NavigationPolygon::remove_outline); - ObjectTypeDB::bind_method(_MD("clear_outlines"),&NavigationPolygon::clear_outlines); - ObjectTypeDB::bind_method(_MD("make_polygons_from_outlines"),&NavigationPolygon::make_polygons_from_outlines); + ClassDB::bind_method(_MD("add_outline","outline"),&NavigationPolygon::add_outline); + ClassDB::bind_method(_MD("add_outline_at_index","outline","index"),&NavigationPolygon::add_outline_at_index); + ClassDB::bind_method(_MD("get_outline_count"),&NavigationPolygon::get_outline_count); + ClassDB::bind_method(_MD("set_outline","idx","outline"),&NavigationPolygon::set_outline); + ClassDB::bind_method(_MD("get_outline","idx"),&NavigationPolygon::get_outline); + ClassDB::bind_method(_MD("remove_outline","idx"),&NavigationPolygon::remove_outline); + ClassDB::bind_method(_MD("clear_outlines"),&NavigationPolygon::clear_outlines); + ClassDB::bind_method(_MD("make_polygons_from_outlines"),&NavigationPolygon::make_polygons_from_outlines); - ObjectTypeDB::bind_method(_MD("_set_polygons","polygons"),&NavigationPolygon::_set_polygons); - ObjectTypeDB::bind_method(_MD("_get_polygons"),&NavigationPolygon::_get_polygons); + ClassDB::bind_method(_MD("_set_polygons","polygons"),&NavigationPolygon::_set_polygons); + ClassDB::bind_method(_MD("_get_polygons"),&NavigationPolygon::_get_polygons); - ObjectTypeDB::bind_method(_MD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines); - ObjectTypeDB::bind_method(_MD("_get_outlines"),&NavigationPolygon::_get_outlines); + ClassDB::bind_method(_MD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines); + ClassDB::bind_method(_MD("_get_outlines"),&NavigationPolygon::_get_outlines); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices")); + ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices")); ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons")); ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"outlines",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_outlines"),_SCS("_get_outlines")); } @@ -310,7 +310,7 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) { if (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) update(); -// update_gizmo(); + //update_gizmo(); } bool NavigationPolygonInstance::is_enabled() const { @@ -368,7 +368,7 @@ void NavigationPolygonInstance::_notification(int p_what) { if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) { - DVector<Vector2> verts=navpoly->get_vertices(); + PoolVector<Vector2> verts=navpoly->get_vertices(); int vsize = verts.size(); if (vsize<3) return; @@ -385,7 +385,7 @@ void NavigationPolygonInstance::_notification(int p_what) { vertices.resize(vsize); colors.resize(vsize); { - DVector<Vector2>::Read vr = verts.read(); + PoolVector<Vector2>::Read vr = verts.read(); for(int i=0;i<vsize;i++) { vertices[i]=vr[i]; colors[i]=color; @@ -459,7 +459,7 @@ void NavigationPolygonInstance::_navpoly_changed() { String NavigationPolygonInstance::get_configuration_warning() const { - if (!is_visible() || !is_inside_tree()) + if (!is_visible_in_tree() || !is_inside_tree()) return String(); if (!navpoly.is_valid()) { @@ -480,13 +480,13 @@ String NavigationPolygonInstance::get_configuration_warning() const { void NavigationPolygonInstance::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon); - ObjectTypeDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon); + ClassDB::bind_method(_MD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon); + ClassDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon); - ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled); - ObjectTypeDB::bind_method(_MD("is_enabled"),&NavigationPolygonInstance::is_enabled); + ClassDB::bind_method(_MD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled); + ClassDB::bind_method(_MD("is_enabled"),&NavigationPolygonInstance::is_enabled); - ObjectTypeDB::bind_method(_MD("_navpoly_changed"),&NavigationPolygonInstance::_navpoly_changed); + ClassDB::bind_method(_MD("_navpoly_changed"),&NavigationPolygonInstance::_navpoly_changed); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navpoly",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon"),_SCS("set_navigation_polygon"),_SCS("get_navigation_polygon")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled")); @@ -497,5 +497,6 @@ NavigationPolygonInstance::NavigationPolygonInstance() { navigation=NULL; nav_id=-1; enabled=true; + set_notify_transform(true); } diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h index c40933cf7a..7f1762b6f5 100644 --- a/scene/2d/navigation_polygon.h +++ b/scene/2d/navigation_polygon.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,14 +34,14 @@ class NavigationPolygon : public Resource { - OBJ_TYPE( NavigationPolygon, Resource ); + GDCLASS( NavigationPolygon, Resource ); - DVector<Vector2> vertices; + PoolVector<Vector2> vertices; struct Polygon { Vector<int> indices; }; Vector<Polygon> polygons; - Vector< DVector<Vector2> > outlines; + Vector< PoolVector<Vector2> > outlines; protected: @@ -57,16 +57,16 @@ public: - void set_vertices(const DVector<Vector2>& p_vertices); - DVector<Vector2> get_vertices() const; + void set_vertices(const PoolVector<Vector2>& p_vertices); + PoolVector<Vector2> get_vertices() const; void add_polygon(const Vector<int>& p_polygon); int get_polygon_count() const; - void add_outline(const DVector<Vector2>& p_outline); - void add_outline_at_index(const DVector<Vector2>& p_outline,int p_index); - void set_outline(int p_idx,const DVector<Vector2>& p_outline); - DVector<Vector2> get_outline(int p_idx) const; + void add_outline(const PoolVector<Vector2>& p_outline); + void add_outline_at_index(const PoolVector<Vector2>& p_outline,int p_index); + void set_outline(int p_idx,const PoolVector<Vector2>& p_outline); + PoolVector<Vector2> get_outline(int p_idx) const; void remove_outline(int p_idx); int get_outline_count() const; @@ -84,7 +84,7 @@ class Navigation2D; class NavigationPolygonInstance : public Node2D { - OBJ_TYPE(NavigationPolygonInstance,Node2D); + GDCLASS(NavigationPolygonInstance,Node2D); bool enabled; int nav_id; diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index b3f925cb14..fb71a5b536 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -51,8 +51,8 @@ bool Node2D::edit_has_pivot() const { Variant Node2D::edit_get_state() const { Array state; - state.push_back(get_pos()); - state.push_back(get_rot()); + state.push_back(get_position()); + state.push_back(get_rotation()); state.push_back(get_scale()); return state; @@ -92,7 +92,7 @@ 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; + Transform2D postxf; postxf.set_rotation_and_scale(angle,_scale); new_pos = postxf.xform(new_pos); @@ -124,7 +124,7 @@ void Node2D::_update_xform_values() { void Node2D::_update_transform() { - Matrix32 mat(angle,pos); + Transform2D mat(angle,pos); _mat.set_rotation_and_scale(angle,_scale); _mat.elements[2]=pos; @@ -137,7 +137,7 @@ void Node2D::_update_transform() { _notify_transform(); } -void Node2D::set_pos(const Point2& p_pos) { +void Node2D::set_position(const Point2& p_pos) { if (_xform_dirty) ((Node2D*)this)->_update_xform_values(); @@ -148,7 +148,7 @@ void Node2D::set_pos(const Point2& p_pos) { } -void Node2D::set_rot(float p_radians) { +void Node2D::set_rotation(float p_radians) { if (_xform_dirty) ((Node2D*)this)->_update_xform_values(); @@ -157,9 +157,9 @@ void Node2D::set_rot(float p_radians) { _change_notify("transform/rot"); } -void Node2D::set_rotd(float p_degrees) { +void Node2D::set_rotation_in_degrees(float p_degrees) { - set_rot(Math::deg2rad(p_degrees)); + set_rotation(Math::deg2rad(p_degrees)); } // Kept for compatibility after rename to set_rotd. @@ -167,7 +167,7 @@ void Node2D::set_rotd(float p_degrees) { void Node2D::_set_rotd(float p_degrees) { WARN_PRINT("Deprecated method Node2D._set_rotd(): This method was renamed to set_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotd(p_degrees); + set_rotation_in_degrees(p_degrees); } void Node2D::set_scale(const Size2& p_scale) { @@ -184,28 +184,28 @@ void Node2D::set_scale(const Size2& p_scale) { } -Point2 Node2D::get_pos() const { +Point2 Node2D::get_position() const { if (_xform_dirty) ((Node2D*)this)->_update_xform_values(); return pos; } -float Node2D::get_rot() const { +float Node2D::get_rotation() const { if (_xform_dirty) ((Node2D*)this)->_update_xform_values(); return angle; } -float Node2D::get_rotd() const { +float Node2D::get_rotation_in_degrees() const { - return Math::rad2deg(get_rot()); + return Math::rad2deg(get_rotation()); } // Kept for compatibility after rename to get_rotd. // Could be removed after a couple releases. float Node2D::_get_rotd() const { WARN_PRINT("Deprecated method Node2D._get_rotd(): This method was renamed to get_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotd(); + return get_rotation_in_degrees(); } Size2 Node2D::get_scale() const { if (_xform_dirty) @@ -222,7 +222,7 @@ void Node2D::_notification(int p_what) { } } -Matrix32 Node2D::get_transform() const { +Transform2D Node2D::get_transform() const { return _mat; } @@ -240,17 +240,17 @@ Rect2 Node2D::get_item_rect() const { void Node2D::rotate(float p_radians) { - set_rot( get_rot() + p_radians); + set_rotation( get_rotation() + p_radians); } void Node2D::translate(const Vector2& p_amount) { - set_pos( get_pos() + p_amount ); + set_position( get_position() + p_amount ); } void Node2D::global_translate(const Vector2& p_amount) { - set_global_pos( get_global_pos() + p_amount ); + set_global_position( get_global_position() + p_amount ); } void Node2D::scale(const Size2& p_amount) { @@ -261,66 +261,66 @@ void Node2D::scale(const Size2& p_amount) { void Node2D::move_x(float p_delta,bool p_scaled){ - Matrix32 t = get_transform(); + Transform2D t = get_transform(); Vector2 m = t[0]; if (!p_scaled) m.normalize(); - set_pos(t[2]+m*p_delta); + set_position(t[2]+m*p_delta); } void Node2D::move_y(float p_delta,bool p_scaled){ - Matrix32 t = get_transform(); + Transform2D t = get_transform(); Vector2 m = t[1]; if (!p_scaled) m.normalize(); - set_pos(t[2]+m*p_delta); + set_position(t[2]+m*p_delta); } -Point2 Node2D::get_global_pos() const { +Point2 Node2D::get_global_position() const { return get_global_transform().get_origin(); } -void Node2D::set_global_pos(const Point2& p_pos) { +void Node2D::set_global_position(const Point2& p_pos) { - Matrix32 inv; + Transform2D inv; CanvasItem *pi = get_parent_item(); if (pi) { inv = pi->get_global_transform().affine_inverse(); - set_pos(inv.xform(p_pos)); + set_position(inv.xform(p_pos)); } else { - set_pos(p_pos); + set_position(p_pos); } } -float Node2D::get_global_rot() const { +float Node2D::get_global_rotation() const { return get_global_transform().get_rotation(); } -void Node2D::set_global_rot(float p_radians) { +void Node2D::set_global_rotation(float p_radians) { CanvasItem *pi = get_parent_item(); if (pi) { const float parent_global_rot = pi->get_global_transform().get_rotation(); - set_rot(p_radians - parent_global_rot); + set_rotation(p_radians - parent_global_rot); } else { - set_rot(p_radians); + set_rotation(p_radians); } } -float Node2D::get_global_rotd() const { +float Node2D::get_global_rotation_in_degrees() const { - return Math::rad2deg(get_global_rot()); + return Math::rad2deg(get_global_rotation()); } -void Node2D::set_global_rotd(float p_degrees) { +void Node2D::set_global_rotation_in_degrees(float p_degrees) { - set_global_rot(Math::deg2rad(p_degrees)); + set_global_rotation(Math::deg2rad(p_degrees)); } @@ -342,7 +342,7 @@ void Node2D::set_global_scale(const Size2& p_scale) { } -void Node2D::set_transform(const Matrix32& p_transform) { +void Node2D::set_transform(const Transform2D& p_transform) { _mat=p_transform; _xform_dirty=true; @@ -355,7 +355,7 @@ void Node2D::set_transform(const Matrix32& p_transform) { _notify_transform(); } -void Node2D::set_global_transform(const Matrix32& p_transform) { +void Node2D::set_global_transform(const Transform2D& p_transform) { CanvasItem *pi = get_parent_item(); if (pi) @@ -394,14 +394,14 @@ int Node2D::get_z() const{ return z; } -Matrix32 Node2D::get_relative_transform_to_parent(const Node *p_parent) const { +Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const { if (p_parent==this) - return Matrix32(); + return Transform2D(); Node2D *parent_2d = get_parent()->cast_to<Node2D>(); - ERR_FAIL_COND_V(!parent_2d,Matrix32()); + ERR_FAIL_COND_V(!parent_2d,Transform2D()); if (p_parent==parent_2d) return get_transform(); else @@ -423,56 +423,67 @@ void Node2D::_bind_methods() { // TODO: Obsolete those two methods (old name) properly (GH-4397) - ObjectTypeDB::bind_method(_MD("_get_rotd"),&Node2D::_get_rotd); - ObjectTypeDB::bind_method(_MD("_set_rotd","degrees"),&Node2D::_set_rotd); - - ObjectTypeDB::bind_method(_MD("set_pos","pos"),&Node2D::set_pos); - ObjectTypeDB::bind_method(_MD("set_rot","radians"),&Node2D::set_rot); - ObjectTypeDB::bind_method(_MD("set_rotd","degrees"),&Node2D::set_rotd); - ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Node2D::set_scale); - - ObjectTypeDB::bind_method(_MD("get_pos"),&Node2D::get_pos); - ObjectTypeDB::bind_method(_MD("get_rot"),&Node2D::get_rot); - ObjectTypeDB::bind_method(_MD("get_rotd"),&Node2D::get_rotd); - ObjectTypeDB::bind_method(_MD("get_scale"),&Node2D::get_scale); - - 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); - ObjectTypeDB::bind_method(_MD("set_global_rot","radians"),&Node2D::set_global_rot); - ObjectTypeDB::bind_method(_MD("get_global_rot"),&Node2D::get_global_rot); - ObjectTypeDB::bind_method(_MD("set_global_rotd","degrees"),&Node2D::set_global_rotd); - ObjectTypeDB::bind_method(_MD("get_global_rotd"),&Node2D::get_global_rotd); - ObjectTypeDB::bind_method(_MD("set_global_scale","scale"),&Node2D::set_global_scale); - ObjectTypeDB::bind_method(_MD("get_global_scale"),&Node2D::get_global_scale); - - ObjectTypeDB::bind_method(_MD("set_transform","xform"),&Node2D::set_transform); - ObjectTypeDB::bind_method(_MD("set_global_transform","xform"),&Node2D::set_global_transform); - - ObjectTypeDB::bind_method(_MD("look_at","point"),&Node2D::look_at); - ObjectTypeDB::bind_method(_MD("get_angle_to","point"),&Node2D::get_angle_to); - - ObjectTypeDB::bind_method(_MD("set_z","z"),&Node2D::set_z); - ObjectTypeDB::bind_method(_MD("get_z"),&Node2D::get_z); - - ObjectTypeDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative); - ObjectTypeDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative); - - ObjectTypeDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot); - - ObjectTypeDB::bind_method(_MD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent); - - ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"transform/pos"),_SCS("set_pos"),_SCS("get_pos")); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"transform/rot",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("set_rotd"),_SCS("get_rotd")); - ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"transform/scale"),_SCS("set_scale"),_SCS("get_scale")); - ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z/z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z")); - ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z/relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative")); + ClassDB::bind_method(_MD("_get_rotd"),&Node2D::_get_rotd); + ClassDB::bind_method(_MD("_set_rotd","degrees"),&Node2D::_set_rotd); + + ClassDB::bind_method(_MD("set_position","pos"),&Node2D::set_position); + ClassDB::bind_method(_MD("set_rotation","radians"),&Node2D::set_rotation); + ClassDB::bind_method(_MD("set_rotation_in_degrees","degrees"),&Node2D::set_rotation_in_degrees); + ClassDB::bind_method(_MD("set_scale","scale"),&Node2D::set_scale); + + ClassDB::bind_method(_MD("get_position"),&Node2D::get_position); + ClassDB::bind_method(_MD("get_rotation"),&Node2D::get_rotation); + ClassDB::bind_method(_MD("get_rotation_in_degrees"),&Node2D::get_rotation_in_degrees); + ClassDB::bind_method(_MD("get_scale"),&Node2D::get_scale); + + ClassDB::bind_method(_MD("rotate","radians"),&Node2D::rotate); + ClassDB::bind_method(_MD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false)); + ClassDB::bind_method(_MD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false)); + ClassDB::bind_method(_MD("translate","offset"),&Node2D::translate); + ClassDB::bind_method(_MD("global_translate","offset"),&Node2D::global_translate); + ClassDB::bind_method(_MD("scale","ratio"),&Node2D::scale); + + ClassDB::bind_method(_MD("set_global_position","pos"),&Node2D::set_global_position); + ClassDB::bind_method(_MD("get_global_position"),&Node2D::get_global_position); + ClassDB::bind_method(_MD("set_global_rotation","radians"),&Node2D::set_global_rotation); + ClassDB::bind_method(_MD("get_global_rotation"),&Node2D::get_global_rotation); + ClassDB::bind_method(_MD("set_global_rotation_in_degrees","degrees"),&Node2D::set_global_rotation_in_degrees); + ClassDB::bind_method(_MD("get_global_rotation_in_degrees"),&Node2D::get_global_rotation_in_degrees); + ClassDB::bind_method(_MD("set_global_scale","scale"),&Node2D::set_global_scale); + ClassDB::bind_method(_MD("get_global_scale"),&Node2D::get_global_scale); + + ClassDB::bind_method(_MD("set_transform","xform"),&Node2D::set_transform); + ClassDB::bind_method(_MD("set_global_transform","xform"),&Node2D::set_global_transform); + + ClassDB::bind_method(_MD("look_at","point"),&Node2D::look_at); + ClassDB::bind_method(_MD("get_angle_to","point"),&Node2D::get_angle_to); + + ClassDB::bind_method(_MD("set_z","z"),&Node2D::set_z); + ClassDB::bind_method(_MD("get_z"),&Node2D::get_z); + + ClassDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative); + ClassDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative); + + ClassDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot); + + ClassDB::bind_method(_MD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent); + + ADD_GROUP("Transform",""); + ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"position"),_SCS("set_position"),_SCS("get_position")); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_rotation"),_SCS("get_rotation")); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation_deg",PROPERTY_HINT_RANGE,"-1440,1440,0.1",PROPERTY_USAGE_EDITOR),_SCS("set_rotation_in_degrees"),_SCS("get_rotation_in_degrees")); + ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"scale"),_SCS("set_scale"),_SCS("get_scale")); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"transform",PROPERTY_HINT_NONE,"",0),_SCS("set_transform"),_SCS("get_transform")); + + ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_position",PROPERTY_HINT_NONE,"",0),_SCS("set_global_position"),_SCS("get_global_position")); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation"),_SCS("get_global_rotation")); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation_deg",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation_in_degrees"),_SCS("get_global_rotation_in_degrees")); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_scale",PROPERTY_HINT_NONE,"",0),_SCS("set_global_scale"),_SCS("get_global_scale")); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"global_transform",PROPERTY_HINT_NONE,"",0),_SCS("set_global_transform"),_SCS("get_global_transform")); + + ADD_GROUP("Z",""); + ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z")); + ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z_as_relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative")); } diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index b31ee08af6..2cceef0f06 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ class Node2D : public CanvasItem { - OBJ_TYPE(Node2D, CanvasItem ); + GDCLASS(Node2D, CanvasItem ); Point2 pos; float angle; @@ -41,7 +41,7 @@ class Node2D : public CanvasItem { int z; bool z_relative; - Matrix32 _mat; + Transform2D _mat; bool _xform_dirty; @@ -69,9 +69,9 @@ public: virtual Point2 edit_get_pivot() const; virtual bool edit_has_pivot() const; - void set_pos(const Point2& p_pos); - void set_rot(float p_radians); - void set_rotd(float p_degrees); + void set_position(const Point2& p_pos); + void set_rotation(float p_radians); + void set_rotation_in_degrees(float p_degrees); void set_scale(const Size2& p_scale); void rotate(float p_radians); @@ -81,22 +81,22 @@ public: void global_translate(const Vector2& p_amount); void scale(const Size2& p_amount); - Point2 get_pos() const; - float get_rot() const; - float get_rotd() const; + Point2 get_position() const; + float get_rotation() const; + float get_rotation_in_degrees() const; Size2 get_scale() const; - Point2 get_global_pos() const; - float get_global_rot() const; - float get_global_rotd() const; + Point2 get_global_position() const; + float get_global_rotation() const; + float get_global_rotation_in_degrees() const; Size2 get_global_scale() const; virtual Rect2 get_item_rect() const; - void set_transform(const Matrix32& p_transform); - void set_global_transform(const Matrix32& p_transform); - void set_global_pos(const Point2& p_pos); - void set_global_rot(float p_radians); - void set_global_rotd(float p_degrees); + void set_transform(const Transform2D& p_transform); + void set_global_transform(const Transform2D& p_transform); + void set_global_position(const Point2& p_pos); + void set_global_rotation(float p_radians); + void set_global_rotation_in_degrees(float p_degrees); void set_global_scale(const Size2& p_scale); void set_z(int p_z); @@ -108,9 +108,9 @@ public: void set_z_as_relative(bool p_enabled); bool is_z_relative() const; - Matrix32 get_relative_transform_to_parent(const Node *p_parent) const; + Transform2D get_relative_transform_to_parent(const Node *p_parent) const; - Matrix32 get_transform() const; + Transform2D get_transform() const; Node2D(); }; diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index 1b6ab66fcc..1e6a449fce 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -50,7 +50,7 @@ void ParallaxBackground::_notification(int p_what) { } -void ParallaxBackground::_camera_moved(const Matrix32& p_transform) { +void ParallaxBackground::_camera_moved(const Transform2D& p_transform) { set_scroll_offset(p_transform.get_origin()); @@ -189,27 +189,28 @@ Vector2 ParallaxBackground::get_final_offset() const { void ParallaxBackground::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved); - ObjectTypeDB::bind_method(_MD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset); - ObjectTypeDB::bind_method(_MD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset); - ObjectTypeDB::bind_method(_MD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset); - ObjectTypeDB::bind_method(_MD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset); - ObjectTypeDB::bind_method(_MD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale); - ObjectTypeDB::bind_method(_MD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale); - ObjectTypeDB::bind_method(_MD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin); - ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin); - ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end); - ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end); - ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom); - ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom); - - - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_offset"),_SCS("set_scroll_base_offset"),_SCS("get_scroll_base_offset")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end")); - ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom")); + ClassDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved); + ClassDB::bind_method(_MD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset); + ClassDB::bind_method(_MD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset); + ClassDB::bind_method(_MD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset); + ClassDB::bind_method(_MD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset); + ClassDB::bind_method(_MD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale); + ClassDB::bind_method(_MD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale); + ClassDB::bind_method(_MD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin); + ClassDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin); + ClassDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end); + ClassDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end); + ClassDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom); + ClassDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom); + + + ADD_GROUP("Scroll","scroll_"); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_offset"),_SCS("set_scroll_base_offset"),_SCS("get_scroll_base_offset")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll_limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end")); + ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll_ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom")); } diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h index c00cd52f26..caef4962e8 100644 --- a/scene/2d/parallax_background.h +++ b/scene/2d/parallax_background.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class ParallaxBackground : public CanvasLayer { - OBJ_TYPE( ParallaxBackground, CanvasLayer ); + GDCLASS( ParallaxBackground, CanvasLayer ); Point2 offset; float scale; @@ -50,7 +50,7 @@ class ParallaxBackground : public CanvasLayer { void _update_scroll(); protected: - void _camera_moved(const Matrix32& p_transform); + void _camera_moved(const Transform2D& p_transform); void _notification(int p_what); static void _bind_methods(); diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 05136de5d6..9aa6640727 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -107,7 +107,7 @@ void ParallaxLayer::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { - orig_offset=get_pos(); + orig_offset=get_position(); orig_scale=get_scale(); _update_mirroring(); } break; @@ -132,7 +132,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2& p_offset,float p_sca new_ofs.y -= den*ceil(new_ofs.y/den); } - set_pos(new_ofs); + set_position(new_ofs); set_scale(Vector2(1,1)*p_scale); @@ -150,16 +150,17 @@ String ParallaxLayer::get_configuration_warning() const { void ParallaxLayer::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale); - ObjectTypeDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale); - ObjectTypeDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset); - ObjectTypeDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset); - ObjectTypeDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring); - ObjectTypeDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring); - - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring")); + ClassDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale); + ClassDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale); + ClassDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset); + ClassDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset); + ClassDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring); + ClassDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring); + + ADD_GROUP("Motion","motion_"); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion_mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring")); } diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h index 6b1d73ea66..1b3d67af5e 100644 --- a/scene/2d/parallax_layer.h +++ b/scene/2d/parallax_layer.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ class ParallaxLayer : public Node2D { - OBJ_TYPE( ParallaxLayer, Node2D ); + GDCLASS( ParallaxLayer, Node2D ); Point2 orig_offset; Point2 orig_scale; diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 3101f616d6..cd99f30f6d 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -98,7 +98,7 @@ void ParticleAttractor2D::_set_owner(Particles2D* p_owner) { return; if (owner) { - owner->disconnect("exit_tree",this,"_owner_exited"); + owner->disconnect("tree_exited",this,"_owner_exited"); owner->attractors.erase(this); owner=NULL; } @@ -106,30 +106,30 @@ void ParticleAttractor2D::_set_owner(Particles2D* p_owner) { if (owner) { - owner->connect("exit_tree",this,"_owner_exited",varray(),CONNECT_ONESHOT); + owner->connect("tree_exited",this,"_owner_exited",varray(),CONNECT_ONESHOT); owner->attractors.insert(this); } } void ParticleAttractor2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&ParticleAttractor2D::set_enabled); - ObjectTypeDB::bind_method(_MD("is_enabled"),&ParticleAttractor2D::is_enabled); + ClassDB::bind_method(_MD("set_enabled","enabled"),&ParticleAttractor2D::set_enabled); + ClassDB::bind_method(_MD("is_enabled"),&ParticleAttractor2D::is_enabled); - ObjectTypeDB::bind_method(_MD("set_radius","radius"),&ParticleAttractor2D::set_radius); - ObjectTypeDB::bind_method(_MD("get_radius"),&ParticleAttractor2D::get_radius); + ClassDB::bind_method(_MD("set_radius","radius"),&ParticleAttractor2D::set_radius); + ClassDB::bind_method(_MD("get_radius"),&ParticleAttractor2D::get_radius); - ObjectTypeDB::bind_method(_MD("set_disable_radius","radius"),&ParticleAttractor2D::set_disable_radius); - ObjectTypeDB::bind_method(_MD("get_disable_radius"),&ParticleAttractor2D::get_disable_radius); + ClassDB::bind_method(_MD("set_disable_radius","radius"),&ParticleAttractor2D::set_disable_radius); + ClassDB::bind_method(_MD("get_disable_radius"),&ParticleAttractor2D::get_disable_radius); - ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&ParticleAttractor2D::set_gravity); - ObjectTypeDB::bind_method(_MD("get_gravity"),&ParticleAttractor2D::get_gravity); + ClassDB::bind_method(_MD("set_gravity","gravity"),&ParticleAttractor2D::set_gravity); + ClassDB::bind_method(_MD("get_gravity"),&ParticleAttractor2D::get_gravity); - ObjectTypeDB::bind_method(_MD("set_absorption","absorption"),&ParticleAttractor2D::set_absorption); - ObjectTypeDB::bind_method(_MD("get_absorption"),&ParticleAttractor2D::get_absorption); + ClassDB::bind_method(_MD("set_absorption","absorption"),&ParticleAttractor2D::set_absorption); + ClassDB::bind_method(_MD("get_absorption"),&ParticleAttractor2D::get_absorption); - ObjectTypeDB::bind_method(_MD("set_particles_path","path"),&ParticleAttractor2D::set_particles_path); - ObjectTypeDB::bind_method(_MD("get_particles_path"),&ParticleAttractor2D::get_particles_path); + ClassDB::bind_method(_MD("set_particles_path","path"),&ParticleAttractor2D::set_particles_path); + ClassDB::bind_method(_MD("get_particles_path"),&ParticleAttractor2D::get_particles_path); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled")); ADD_PROPERTY(PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),_SCS("set_radius"),_SCS("get_radius")); @@ -270,13 +270,13 @@ void Particles2D::_process_particles(float p_delta) { Particle *pdata=&particles[0]; int particle_count=particles.size(); - Matrix32 xform; + Transform2D xform; if (!local_space) xform=get_global_transform(); active_count=0; - DVector<Point2>::Read r; + PoolVector<Point2>::Read r; int emission_point_count=0; if (emission_points.size()) { @@ -293,13 +293,13 @@ void Particles2D::_process_particles(float p_delta) { } int idx=0; - Matrix32 m; + Transform2D m; if (local_space) { m= get_global_transform().affine_inverse(); } for (Set<ParticleAttractor2D*>::Element *E=attractors.front();E;E=E->next()) { - attractor_cache[idx].pos=m.xform( E->get()->get_global_pos() ); + attractor_cache[idx].pos=m.xform( E->get()->get_global_position() ); attractor_cache[idx].attractor=E->get(); idx++; } @@ -391,7 +391,7 @@ void Particles2D::_process_particles(float p_delta) { float orbitvel = (param[PARAM_ORBIT_VELOCITY]+param[PARAM_ORBIT_VELOCITY]*randomness[PARAM_ORBIT_VELOCITY]*_rand_from_seed(&rand_seed)); if (orbitvel!=0) { Vector2 rel = p.pos - xform.elements[2]; - Matrix32 rot(orbitvel*frame_time,Vector2()); + Transform2D rot(orbitvel*frame_time,Vector2()); p.pos = rot.xform(rel) + xform.elements[2]; } @@ -507,7 +507,7 @@ void Particles2D::_notification(int p_what) { if (texture.is_valid()) texrid = texture->get_rid(); - Matrix32 invxform; + Transform2D invxform; if (!local_space) invxform=get_global_transform().affine_inverse(); @@ -573,7 +573,7 @@ void Particles2D::_notification(int p_what) { //Rect2 r = Rect2(Vecto,rectsize); - Matrix32 xform; + Transform2D xform; if (p.rot) { @@ -992,12 +992,12 @@ int Particles2D::get_v_frames() const{ -void Particles2D::set_emission_points(const DVector<Vector2>& p_points) { +void Particles2D::set_emission_points(const PoolVector<Vector2>& p_points) { emission_points=p_points; } -DVector<Vector2> Particles2D::get_emission_points() const{ +PoolVector<Vector2> Particles2D::get_emission_points() const{ return emission_points; } @@ -1013,80 +1013,80 @@ void Particles2D::reset() { void Particles2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_emitting","active"),&Particles2D::set_emitting); - ObjectTypeDB::bind_method(_MD("is_emitting"),&Particles2D::is_emitting); + ClassDB::bind_method(_MD("set_emitting","active"),&Particles2D::set_emitting); + ClassDB::bind_method(_MD("is_emitting"),&Particles2D::is_emitting); - ObjectTypeDB::bind_method(_MD("set_amount","amount"),&Particles2D::set_amount); - ObjectTypeDB::bind_method(_MD("get_amount"),&Particles2D::get_amount); + ClassDB::bind_method(_MD("set_amount","amount"),&Particles2D::set_amount); + ClassDB::bind_method(_MD("get_amount"),&Particles2D::get_amount); - ObjectTypeDB::bind_method(_MD("set_lifetime","lifetime"),&Particles2D::set_lifetime); - ObjectTypeDB::bind_method(_MD("get_lifetime"),&Particles2D::get_lifetime); + ClassDB::bind_method(_MD("set_lifetime","lifetime"),&Particles2D::set_lifetime); + ClassDB::bind_method(_MD("get_lifetime"),&Particles2D::get_lifetime); - ObjectTypeDB::bind_method(_MD("set_time_scale","time_scale"),&Particles2D::set_time_scale); - ObjectTypeDB::bind_method(_MD("get_time_scale"),&Particles2D::get_time_scale); + ClassDB::bind_method(_MD("set_time_scale","time_scale"),&Particles2D::set_time_scale); + ClassDB::bind_method(_MD("get_time_scale"),&Particles2D::get_time_scale); - ObjectTypeDB::bind_method(_MD("set_pre_process_time","time"),&Particles2D::set_pre_process_time); - ObjectTypeDB::bind_method(_MD("get_pre_process_time"),&Particles2D::get_pre_process_time); + ClassDB::bind_method(_MD("set_pre_process_time","time"),&Particles2D::set_pre_process_time); + ClassDB::bind_method(_MD("get_pre_process_time"),&Particles2D::get_pre_process_time); - ObjectTypeDB::bind_method(_MD("set_emit_timeout","value"),&Particles2D::set_emit_timeout); - ObjectTypeDB::bind_method(_MD("get_emit_timeout"),&Particles2D::get_emit_timeout); + ClassDB::bind_method(_MD("set_emit_timeout","value"),&Particles2D::set_emit_timeout); + ClassDB::bind_method(_MD("get_emit_timeout"),&Particles2D::get_emit_timeout); - ObjectTypeDB::bind_method(_MD("set_param","param","value"),&Particles2D::set_param); - ObjectTypeDB::bind_method(_MD("get_param","param"),&Particles2D::get_param); + ClassDB::bind_method(_MD("set_param","param","value"),&Particles2D::set_param); + ClassDB::bind_method(_MD("get_param","param"),&Particles2D::get_param); - ObjectTypeDB::bind_method(_MD("set_randomness","param","value"),&Particles2D::set_randomness); - ObjectTypeDB::bind_method(_MD("get_randomness","param"),&Particles2D::get_randomness); + ClassDB::bind_method(_MD("set_randomness","param","value"),&Particles2D::set_randomness); + ClassDB::bind_method(_MD("get_randomness","param"),&Particles2D::get_randomness); - ObjectTypeDB::bind_method(_MD("set_texture:Texture","texture"),&Particles2D::set_texture); - ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Particles2D::get_texture); + ClassDB::bind_method(_MD("set_texture:Texture","texture"),&Particles2D::set_texture); + ClassDB::bind_method(_MD("get_texture:Texture"),&Particles2D::get_texture); - ObjectTypeDB::bind_method(_MD("set_color","color"),&Particles2D::set_color); - ObjectTypeDB::bind_method(_MD("get_color"),&Particles2D::get_color); + ClassDB::bind_method(_MD("set_color","color"),&Particles2D::set_color); + ClassDB::bind_method(_MD("get_color"),&Particles2D::get_color); - ObjectTypeDB::bind_method(_MD("set_color_ramp:ColorRamp","color_ramp"),&Particles2D::set_color_ramp); - ObjectTypeDB::bind_method(_MD("get_color_ramp:ColorRamp"),&Particles2D::get_color_ramp); + ClassDB::bind_method(_MD("set_color_ramp:ColorRamp","color_ramp"),&Particles2D::set_color_ramp); + ClassDB::bind_method(_MD("get_color_ramp:ColorRamp"),&Particles2D::get_color_ramp); - ObjectTypeDB::bind_method(_MD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset); - ObjectTypeDB::bind_method(_MD("get_emissor_offset"),&Particles2D::get_emissor_offset); + ClassDB::bind_method(_MD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset); + ClassDB::bind_method(_MD("get_emissor_offset"),&Particles2D::get_emissor_offset); - ObjectTypeDB::bind_method(_MD("set_flip_h","enable"),&Particles2D::set_flip_h); - ObjectTypeDB::bind_method(_MD("is_flipped_h"),&Particles2D::is_flipped_h); + ClassDB::bind_method(_MD("set_flip_h","enable"),&Particles2D::set_flip_h); + ClassDB::bind_method(_MD("is_flipped_h"),&Particles2D::is_flipped_h); - ObjectTypeDB::bind_method(_MD("set_flip_v","enable"),&Particles2D::set_flip_v); - ObjectTypeDB::bind_method(_MD("is_flipped_v"),&Particles2D::is_flipped_v); + ClassDB::bind_method(_MD("set_flip_v","enable"),&Particles2D::set_flip_v); + ClassDB::bind_method(_MD("is_flipped_v"),&Particles2D::is_flipped_v); - ObjectTypeDB::bind_method(_MD("set_h_frames","enable"),&Particles2D::set_h_frames); - ObjectTypeDB::bind_method(_MD("get_h_frames"),&Particles2D::get_h_frames); + ClassDB::bind_method(_MD("set_h_frames","enable"),&Particles2D::set_h_frames); + ClassDB::bind_method(_MD("get_h_frames"),&Particles2D::get_h_frames); - ObjectTypeDB::bind_method(_MD("set_v_frames","enable"),&Particles2D::set_v_frames); - ObjectTypeDB::bind_method(_MD("get_v_frames"),&Particles2D::get_v_frames); + ClassDB::bind_method(_MD("set_v_frames","enable"),&Particles2D::set_v_frames); + ClassDB::bind_method(_MD("get_v_frames"),&Particles2D::get_v_frames); - ObjectTypeDB::bind_method(_MD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents); - ObjectTypeDB::bind_method(_MD("get_emission_half_extents"),&Particles2D::get_emission_half_extents); + ClassDB::bind_method(_MD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents); + ClassDB::bind_method(_MD("get_emission_half_extents"),&Particles2D::get_emission_half_extents); - ObjectTypeDB::bind_method(_MD("set_color_phases","phases"),&Particles2D::set_color_phases); - ObjectTypeDB::bind_method(_MD("get_color_phases"),&Particles2D::get_color_phases); + ClassDB::bind_method(_MD("set_color_phases","phases"),&Particles2D::set_color_phases); + ClassDB::bind_method(_MD("get_color_phases"),&Particles2D::get_color_phases); - ObjectTypeDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles2D::set_color_phase_color); - ObjectTypeDB::bind_method(_MD("get_color_phase_color","phase"),&Particles2D::get_color_phase_color); + ClassDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles2D::set_color_phase_color); + ClassDB::bind_method(_MD("get_color_phase_color","phase"),&Particles2D::get_color_phase_color); - ObjectTypeDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles2D::set_color_phase_pos); - ObjectTypeDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos); + ClassDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles2D::set_color_phase_pos); + ClassDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos); - ObjectTypeDB::bind_method(_MD("pre_process","time"),&Particles2D::pre_process); - ObjectTypeDB::bind_method(_MD("reset"),&Particles2D::reset); + ClassDB::bind_method(_MD("pre_process","time"),&Particles2D::pre_process); + ClassDB::bind_method(_MD("reset"),&Particles2D::reset); - ObjectTypeDB::bind_method(_MD("set_use_local_space","enable"),&Particles2D::set_use_local_space); - ObjectTypeDB::bind_method(_MD("is_using_local_space"),&Particles2D::is_using_local_space); + ClassDB::bind_method(_MD("set_use_local_space","enable"),&Particles2D::set_use_local_space); + ClassDB::bind_method(_MD("is_using_local_space"),&Particles2D::is_using_local_space); - ObjectTypeDB::bind_method(_MD("set_initial_velocity","velocity"),&Particles2D::set_initial_velocity); - ObjectTypeDB::bind_method(_MD("get_initial_velocity"),&Particles2D::get_initial_velocity); + ClassDB::bind_method(_MD("set_initial_velocity","velocity"),&Particles2D::set_initial_velocity); + ClassDB::bind_method(_MD("get_initial_velocity"),&Particles2D::get_initial_velocity); - ObjectTypeDB::bind_method(_MD("set_explosiveness","amount"),&Particles2D::set_explosiveness); - ObjectTypeDB::bind_method(_MD("get_explosiveness"),&Particles2D::get_explosiveness); + ClassDB::bind_method(_MD("set_explosiveness","amount"),&Particles2D::set_explosiveness); + ClassDB::bind_method(_MD("get_explosiveness"),&Particles2D::get_explosiveness); - ObjectTypeDB::bind_method(_MD("set_emission_points","points"),&Particles2D::set_emission_points); - ObjectTypeDB::bind_method(_MD("get_emission_points"),&Particles2D::get_emission_points); + ClassDB::bind_method(_MD("set_emission_points","points"),&Particles2D::set_emission_points); + ClassDB::bind_method(_MD("get_emission_points"),&Particles2D::get_emission_points); ADD_PROPERTY(PropertyInfo(Variant::INT,"config/amount",PROPERTY_HINT_EXP_RANGE,"1,1024"),_SCS("set_amount"),_SCS("get_amount") ); ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/lifetime",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_lifetime"),_SCS("get_lifetime") ); @@ -1125,7 +1125,7 @@ void Particles2D::_bind_methods() { ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "color/color"),_SCS("set_color"),_SCS("get_color")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"color/color_ramp",PROPERTY_HINT_RESOURCE_TYPE,"ColorRamp"),_SCS("set_color_ramp"),_SCS("get_color_ramp")); - ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points")); + ADD_PROPERTYNZ(PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points")); BIND_CONSTANT( PARAM_DIRECTION ); BIND_CONSTANT( PARAM_SPREAD ); diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h index b1ae1f5bc1..91f42c5222 100644 --- a/scene/2d/particles_2d.h +++ b/scene/2d/particles_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -36,7 +36,7 @@ class Particles2D; class ParticleAttractor2D : public Node2D { - OBJ_TYPE(ParticleAttractor2D,Node2D); + GDCLASS(ParticleAttractor2D,Node2D); friend class Particles2D; @@ -84,7 +84,7 @@ public: class Particles2D : public Node2D { - OBJ_TYPE(Particles2D, Node2D); + GDCLASS(Particles2D, Node2D); public: enum Parameter { @@ -117,7 +117,6 @@ private: float randomness[PARAM_MAX]; struct Particle { - bool active; Point2 pos; Vector2 velocity; @@ -152,7 +151,7 @@ private: Point2 emissor_offset; Vector2 initial_velocity; Vector2 extents; - DVector<Vector2> emission_points; + PoolVector<Vector2> emission_points; float time; int active_count; @@ -246,8 +245,8 @@ public: void set_initial_velocity(const Vector2& p_velocity); Vector2 get_initial_velocity() const; - void set_emission_points(const DVector<Vector2>& p_points); - DVector<Vector2> get_emission_points() const; + void set_emission_points(const PoolVector<Vector2>& p_points); + PoolVector<Vector2> get_emission_points() const; void pre_process(float p_delta); void reset(); diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 41ca7b1d0f..e1d1920cc5 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -85,9 +85,9 @@ Ref<Curve2D> Path2D::get_curve() const{ void Path2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_curve","curve:Curve2D"),&Path2D::set_curve); - ObjectTypeDB::bind_method(_MD("get_curve:Curve2D","curve"),&Path2D::get_curve); - ObjectTypeDB::bind_method(_MD("_curve_changed"),&Path2D::_curve_changed); + ClassDB::bind_method(_MD("set_curve","curve:Curve2D"),&Path2D::set_curve); + ClassDB::bind_method(_MD("get_curve:Curve2D","curve"),&Path2D::get_curve); + ClassDB::bind_method(_MD("_curve_changed"),&Path2D::_curve_changed); ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), _SCS("set_curve"),_SCS("get_curve")); } @@ -124,7 +124,7 @@ void PathFollow2D::_update_transform() { pos+=n*h_offset; pos+=t*v_offset; - set_rot(t.angle()); + set_rotation(t.angle()); } else { @@ -132,7 +132,7 @@ void PathFollow2D::_update_transform() { pos.y+=v_offset; } - set_pos(pos); + set_position(pos); } @@ -239,7 +239,7 @@ void PathFollow2D::_get_property_list( List<PropertyInfo> *p_list) const{ String PathFollow2D::get_configuration_warning() const { - if (!is_visible() || !is_inside_tree()) + if (!is_visible_in_tree() || !is_inside_tree()) return String(); if (!get_parent() || !get_parent()->cast_to<Path2D>()) { @@ -252,26 +252,26 @@ String PathFollow2D::get_configuration_warning() const { void PathFollow2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_offset","offset"),&PathFollow2D::set_offset); - ObjectTypeDB::bind_method(_MD("get_offset"),&PathFollow2D::get_offset); + ClassDB::bind_method(_MD("set_offset","offset"),&PathFollow2D::set_offset); + ClassDB::bind_method(_MD("get_offset"),&PathFollow2D::get_offset); - ObjectTypeDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow2D::set_h_offset); - ObjectTypeDB::bind_method(_MD("get_h_offset"),&PathFollow2D::get_h_offset); + ClassDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow2D::set_h_offset); + ClassDB::bind_method(_MD("get_h_offset"),&PathFollow2D::get_h_offset); - ObjectTypeDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow2D::set_v_offset); - ObjectTypeDB::bind_method(_MD("get_v_offset"),&PathFollow2D::get_v_offset); + ClassDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow2D::set_v_offset); + ClassDB::bind_method(_MD("get_v_offset"),&PathFollow2D::get_v_offset); - ObjectTypeDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow2D::set_unit_offset); - ObjectTypeDB::bind_method(_MD("get_unit_offset"),&PathFollow2D::get_unit_offset); + ClassDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow2D::set_unit_offset); + ClassDB::bind_method(_MD("get_unit_offset"),&PathFollow2D::get_unit_offset); - ObjectTypeDB::bind_method(_MD("set_rotate","enable"),&PathFollow2D::set_rotate); - ObjectTypeDB::bind_method(_MD("is_rotating"),&PathFollow2D::is_rotating); + ClassDB::bind_method(_MD("set_rotate","enable"),&PathFollow2D::set_rotate); + ClassDB::bind_method(_MD("is_rotating"),&PathFollow2D::is_rotating); - ObjectTypeDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow2D::set_cubic_interpolation); - ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow2D::get_cubic_interpolation); + ClassDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow2D::set_cubic_interpolation); + ClassDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow2D::get_cubic_interpolation); - ObjectTypeDB::bind_method(_MD("set_loop","loop"),&PathFollow2D::set_loop); - ObjectTypeDB::bind_method(_MD("has_loop"),&PathFollow2D::has_loop); + ClassDB::bind_method(_MD("set_loop","loop"),&PathFollow2D::set_loop); + ClassDB::bind_method(_MD("has_loop"),&PathFollow2D::has_loop); } diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index 84725e7123..4fc26dbf9b 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class Path2D : public Node2D { - OBJ_TYPE( Path2D, Node2D ); + GDCLASS( Path2D, Node2D ); Ref<Curve2D> curve; @@ -58,7 +58,7 @@ public: class PathFollow2D : public Node2D { - OBJ_TYPE(PathFollow2D,Node2D); + GDCLASS(PathFollow2D,Node2D); public: diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp index 3f7c514317..626928a244 100644 --- a/scene/2d/path_texture.cpp +++ b/scene/2d/path_texture.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h index 11a60b1390..cc502a2fa4 100644 --- a/scene/2d/path_texture.h +++ b/scene/2d/path_texture.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -32,7 +32,7 @@ #include "scene/2d/node_2d.h" class PathTexture : public Node2D { - OBJ_TYPE( PathTexture, Node2D ); + GDCLASS( PathTexture, Node2D ); Ref<Texture> begin; Ref<Texture> repeat; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index b973eab22a..feecbd9e20 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -70,51 +70,54 @@ float PhysicsBody2D::get_one_way_collision_max_depth() const{ void PhysicsBody2D::_set_layers(uint32_t p_mask) { - set_layer_mask(p_mask); + set_collision_layer(p_mask); set_collision_mask(p_mask); } uint32_t PhysicsBody2D::_get_layers() const{ - return get_layer_mask(); + return get_collision_layer(); } void PhysicsBody2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask); - ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask); - ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask); - ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask); - - - ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit); - ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit); - - ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody2D::set_layer_mask_bit); - ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody2D::get_layer_mask_bit); - - ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers); - ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers); - ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction); - ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction); - ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth); - ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth); - ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with); - ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with); - ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat - ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); - ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + ClassDB::bind_method(_MD("set_collision_layer","mask"),&PhysicsBody2D::set_collision_layer); + ClassDB::bind_method(_MD("get_collision_layer"),&PhysicsBody2D::get_collision_layer); + ClassDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask); + ClassDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask); + + + ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit); + ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit); + + ClassDB::bind_method(_MD("set_collision_layer_bit","bit","value"),&PhysicsBody2D::set_collision_layer_bit); + ClassDB::bind_method(_MD("get_collision_layer_bit","bit"),&PhysicsBody2D::get_collision_layer_bit); + + ClassDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers); + ClassDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers); + ClassDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction); + ClassDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction); + ClassDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth); + ClassDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth); + ClassDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with); + ClassDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with); + ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_LAYERS_2D_PHYSICS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat + + ADD_GROUP("Collision","collision_"); + ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layer",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); + ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + ADD_GROUP("",""); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction")); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth")); } -void PhysicsBody2D::set_layer_mask(uint32_t p_mask) { +void PhysicsBody2D::set_collision_layer(uint32_t p_mask) { mask=p_mask; Physics2DServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask); } -uint32_t PhysicsBody2D::get_layer_mask() const { +uint32_t PhysicsBody2D::get_collision_layer() const { return mask; } @@ -146,20 +149,20 @@ bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const{ } -void PhysicsBody2D::set_layer_mask_bit(int p_bit, bool p_value) { +void PhysicsBody2D::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t mask = get_layer_mask(); + uint32_t mask = get_collision_layer(); if (p_value) mask|=1<<p_bit; else mask&=~(1<<p_bit); - set_layer_mask(mask); + set_collision_layer(mask); } -bool PhysicsBody2D::get_layer_mask_bit(int p_bit) const{ +bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const{ - return get_layer_mask()&(1<<p_bit); + return get_collision_layer()&(1<<p_bit); } PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) { @@ -224,7 +227,7 @@ void StaticBody2D::_update_xform() { setting=true; - Matrix32 new_xform = get_global_transform(); //obtain the new one + Transform2D new_xform = get_global_transform(); //obtain the new one set_block_transform_notify(true); Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,*pre_xform); //then simulate motion! @@ -268,15 +271,15 @@ real_t StaticBody2D::get_bounce() const{ void StaticBody2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody2D::set_constant_linear_velocity); - ObjectTypeDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody2D::set_constant_angular_velocity); - ObjectTypeDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody2D::get_constant_linear_velocity); - ObjectTypeDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody2D::get_constant_angular_velocity); - ObjectTypeDB::bind_method(_MD("set_friction","friction"),&StaticBody2D::set_friction); - ObjectTypeDB::bind_method(_MD("get_friction"),&StaticBody2D::get_friction); + ClassDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody2D::set_constant_linear_velocity); + ClassDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody2D::set_constant_angular_velocity); + ClassDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody2D::get_constant_linear_velocity); + ClassDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody2D::get_constant_angular_velocity); + ClassDB::bind_method(_MD("set_friction","friction"),&StaticBody2D::set_friction); + ClassDB::bind_method(_MD("get_friction"),&StaticBody2D::get_friction); - ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&StaticBody2D::set_bounce); - ObjectTypeDB::bind_method(_MD("get_bounce"),&StaticBody2D::get_bounce); + ClassDB::bind_method(_MD("set_bounce","bounce"),&StaticBody2D::set_bounce); + ClassDB::bind_method(_MD("get_bounce"),&StaticBody2D::get_bounce); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"constant_linear_velocity"),_SCS("set_constant_linear_velocity"),_SCS("get_constant_linear_velocity")); ADD_PROPERTY(PropertyInfo(Variant::REAL,"constant_angular_velocity"),_SCS("set_constant_angular_velocity"),_SCS("get_constant_angular_velocity")); @@ -313,12 +316,12 @@ void RigidBody2D::_body_enter_tree(ObjectID p_id) { contact_monitor->locked=true; E->get().in_scene=true; - emit_signal(SceneStringNames::get_singleton()->body_enter,node); + emit_signal(SceneStringNames::get_singleton()->body_entered,node); for(int i=0;i<E->get().shapes.size();i++) { - emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_entered,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape); } contact_monitor->locked=false; @@ -338,11 +341,11 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) { contact_monitor->locked=true; - emit_signal(SceneStringNames::get_singleton()->body_exit,node); + emit_signal(SceneStringNames::get_singleton()->body_exited,node); for(int i=0;i<E->get().shapes.size();i++) { - emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_exited,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape); } contact_monitor->locked=false; @@ -372,13 +375,13 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap if (!E) { E = contact_monitor->body_map.insert(objid,BodyState()); -// E->get().rc=0; + //E->get().rc=0; E->get().in_scene=node && node->is_inside_tree(); if (node) { - node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid)); if (E->get().in_scene) { - emit_signal(SceneStringNames::get_singleton()->body_enter,node); + emit_signal(SceneStringNames::get_singleton()->body_entered,node); } } @@ -390,7 +393,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap if (E->get().in_scene) { - emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_local_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_entered,objid,node,p_body_shape,p_local_shape); } } else { @@ -405,17 +408,17 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap if (E->get().shapes.empty()) { if (node) { - 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); + node->disconnect(SceneStringNames::get_singleton()->tree_entered,this,SceneStringNames::get_singleton()->_body_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->tree_exited,this,SceneStringNames::get_singleton()->_body_exit_tree); if (in_scene) - emit_signal(SceneStringNames::get_singleton()->body_exit,obj); + emit_signal(SceneStringNames::get_singleton()->body_exited,obj); } contact_monitor->body_map.erase(E); } if (node && in_scene) { - emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_local_shape); + emit_signal(SceneStringNames::get_singleton()->body_shape_exited,objid,obj,p_body_shape,p_local_shape); } } @@ -491,7 +494,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { int local_shape = state->get_contact_local_shape(i); int shape = state->get_contact_collider_shape(i); -// bool found=false; + //bool found=false; Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj); if (!E) { @@ -879,75 +882,75 @@ bool RigidBody2D::is_contact_monitor_enabled() const { void RigidBody2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_mode","mode"),&RigidBody2D::set_mode); - ObjectTypeDB::bind_method(_MD("get_mode"),&RigidBody2D::get_mode); + ClassDB::bind_method(_MD("set_mode","mode"),&RigidBody2D::set_mode); + ClassDB::bind_method(_MD("get_mode"),&RigidBody2D::get_mode); - ObjectTypeDB::bind_method(_MD("set_mass","mass"),&RigidBody2D::set_mass); - ObjectTypeDB::bind_method(_MD("get_mass"),&RigidBody2D::get_mass); + ClassDB::bind_method(_MD("set_mass","mass"),&RigidBody2D::set_mass); + ClassDB::bind_method(_MD("get_mass"),&RigidBody2D::get_mass); - ObjectTypeDB::bind_method(_MD("get_inertia"),&RigidBody2D::get_inertia); - ObjectTypeDB::bind_method(_MD("set_inertia","inertia"),&RigidBody2D::set_inertia); + ClassDB::bind_method(_MD("get_inertia"),&RigidBody2D::get_inertia); + ClassDB::bind_method(_MD("set_inertia","inertia"),&RigidBody2D::set_inertia); - ObjectTypeDB::bind_method(_MD("set_weight","weight"),&RigidBody2D::set_weight); - ObjectTypeDB::bind_method(_MD("get_weight"),&RigidBody2D::get_weight); + ClassDB::bind_method(_MD("set_weight","weight"),&RigidBody2D::set_weight); + ClassDB::bind_method(_MD("get_weight"),&RigidBody2D::get_weight); - ObjectTypeDB::bind_method(_MD("set_friction","friction"),&RigidBody2D::set_friction); - ObjectTypeDB::bind_method(_MD("get_friction"),&RigidBody2D::get_friction); + ClassDB::bind_method(_MD("set_friction","friction"),&RigidBody2D::set_friction); + ClassDB::bind_method(_MD("get_friction"),&RigidBody2D::get_friction); - ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&RigidBody2D::set_bounce); - ObjectTypeDB::bind_method(_MD("get_bounce"),&RigidBody2D::get_bounce); + ClassDB::bind_method(_MD("set_bounce","bounce"),&RigidBody2D::set_bounce); + ClassDB::bind_method(_MD("get_bounce"),&RigidBody2D::get_bounce); - ObjectTypeDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody2D::set_gravity_scale); - ObjectTypeDB::bind_method(_MD("get_gravity_scale"),&RigidBody2D::get_gravity_scale); + ClassDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody2D::set_gravity_scale); + ClassDB::bind_method(_MD("get_gravity_scale"),&RigidBody2D::get_gravity_scale); - ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody2D::set_linear_damp); - ObjectTypeDB::bind_method(_MD("get_linear_damp"),&RigidBody2D::get_linear_damp); + ClassDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody2D::set_linear_damp); + ClassDB::bind_method(_MD("get_linear_damp"),&RigidBody2D::get_linear_damp); - ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody2D::set_angular_damp); - ObjectTypeDB::bind_method(_MD("get_angular_damp"),&RigidBody2D::get_angular_damp); + ClassDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody2D::set_angular_damp); + ClassDB::bind_method(_MD("get_angular_damp"),&RigidBody2D::get_angular_damp); - ObjectTypeDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody2D::set_linear_velocity); - ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&RigidBody2D::get_linear_velocity); + ClassDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody2D::set_linear_velocity); + ClassDB::bind_method(_MD("get_linear_velocity"),&RigidBody2D::get_linear_velocity); - ObjectTypeDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody2D::set_angular_velocity); - ObjectTypeDB::bind_method(_MD("get_angular_velocity"),&RigidBody2D::get_angular_velocity); + ClassDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody2D::set_angular_velocity); + ClassDB::bind_method(_MD("get_angular_velocity"),&RigidBody2D::get_angular_velocity); - ObjectTypeDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody2D::set_max_contacts_reported); - ObjectTypeDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody2D::get_max_contacts_reported); + ClassDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody2D::set_max_contacts_reported); + ClassDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody2D::get_max_contacts_reported); - ObjectTypeDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody2D::set_use_custom_integrator); - ObjectTypeDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody2D::is_using_custom_integrator); + ClassDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody2D::set_use_custom_integrator); + ClassDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody2D::is_using_custom_integrator); - ObjectTypeDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody2D::set_contact_monitor); - ObjectTypeDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody2D::is_contact_monitor_enabled); + ClassDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody2D::set_contact_monitor); + ClassDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody2D::is_contact_monitor_enabled); - ObjectTypeDB::bind_method(_MD("set_continuous_collision_detection_mode","mode"),&RigidBody2D::set_continuous_collision_detection_mode); - ObjectTypeDB::bind_method(_MD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode); + ClassDB::bind_method(_MD("set_continuous_collision_detection_mode","mode"),&RigidBody2D::set_continuous_collision_detection_mode); + ClassDB::bind_method(_MD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode); - ObjectTypeDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity); - ObjectTypeDB::bind_method(_MD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse); + ClassDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity); + ClassDB::bind_method(_MD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse); - ObjectTypeDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force); - ObjectTypeDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force); + ClassDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force); + ClassDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force); - ObjectTypeDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque); - ObjectTypeDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque); + ClassDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque); + ClassDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque); - ObjectTypeDB::bind_method(_MD("add_force","offset","force"),&RigidBody2D::add_force); + ClassDB::bind_method(_MD("add_force","offset","force"),&RigidBody2D::add_force); - ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping); - ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping); + ClassDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping); + ClassDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping); - ObjectTypeDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep); - ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep); + ClassDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep); + ClassDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep); - ObjectTypeDB::bind_method(_MD("test_motion","motion","margin","result:Physics2DTestMotionResult"),&RigidBody2D::_test_motion,DEFVAL(0.08),DEFVAL(Variant())); + ClassDB::bind_method(_MD("test_motion","motion","margin","result:Physics2DTestMotionResult"),&RigidBody2D::_test_motion,DEFVAL(0.08),DEFVAL(Variant())); - ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&RigidBody2D::_direct_state_changed); - ObjectTypeDB::bind_method(_MD("_body_enter_tree"),&RigidBody2D::_body_enter_tree); - ObjectTypeDB::bind_method(_MD("_body_exit_tree"),&RigidBody2D::_body_exit_tree); + ClassDB::bind_method(_MD("_direct_state_changed"),&RigidBody2D::_direct_state_changed); + ClassDB::bind_method(_MD("_body_enter_tree"),&RigidBody2D::_body_enter_tree); + ClassDB::bind_method(_MD("_body_exit_tree"),&RigidBody2D::_body_exit_tree); - ObjectTypeDB::bind_method(_MD("get_colliding_bodies"),&RigidBody2D::get_colliding_bodies); + ClassDB::bind_method(_MD("get_colliding_bodies"),&RigidBody2D::get_colliding_bodies); BIND_VMETHOD(MethodInfo("_integrate_forces",PropertyInfo(Variant::OBJECT,"state:Physics2DDirectBodyState"))); @@ -963,15 +966,17 @@ void RigidBody2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"velocity/linear"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"velocity/angular"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/linear",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/angular",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp")); - - ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape"))); - ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape"))); - ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body"))); - ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body"))); + ADD_GROUP("Linear","linear_"); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"linear_velocity"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity")); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp")); + ADD_GROUP("Angular","angular_"); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_velocity"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity")); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp")); + + ADD_SIGNAL( MethodInfo("body_shape_entered",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape"))); + ADD_SIGNAL( MethodInfo("body_shape_exited",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape"))); + ADD_SIGNAL( MethodInfo("body_entered",PropertyInfo(Variant::OBJECT,"body"))); + ADD_SIGNAL( MethodInfo("body_exited",PropertyInfo(Variant::OBJECT,"body"))); ADD_SIGNAL( MethodInfo("sleeping_state_changed")); BIND_CONSTANT( MODE_STATIC ); @@ -1042,7 +1047,7 @@ Variant KinematicBody2D::_get_collider() const { void KinematicBody2D::revert_motion() { - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); gt.elements[2]-=travel; travel=Vector2(); set_global_transform(gt); @@ -1058,7 +1063,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { #if 1 - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Physics2DServer::MotionResult result; colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(),gt,p_motion,margin,&result); @@ -1136,8 +1141,10 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { float d = a.distance_to(b); - //if (d<margin) - /// continue; + /* + if (d<margin) + continue; + */ recover_motion+=(b-a)*0.4; } @@ -1148,7 +1155,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); gt.elements[2]+=recover_motion; set_global_transform(gt); @@ -1199,7 +1206,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { } else { //it collided, let's get the rest info in unsafe advance - Matrix32 ugt = get_global_transform(); + Transform2D ugt = get_global_transform(); ugt.elements[2]+=p_motion*unsafe; Physics2DDirectSpaceState::ShapeRestInfo rest_info; bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask); @@ -1223,7 +1230,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { } Vector2 motion=p_motion*safe; - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); gt.elements[2]+=motion; set_global_transform(gt); @@ -1311,10 +1318,10 @@ Array KinematicBody2D::get_move_and_slide_colliders() const{ Vector2 KinematicBody2D::move_to(const Vector2& p_position) { - return move(p_position-get_global_pos()); + return move(p_position-get_global_position()); } -bool KinematicBody2D::test_move(const Matrix32& p_from,const Vector2& p_motion) { +bool KinematicBody2D::test_move(const Transform2D& p_from,const Vector2& p_motion) { ERR_FAIL_COND_V(!is_inside_tree(),false); @@ -1381,29 +1388,29 @@ float KinematicBody2D::get_collision_margin() const{ void KinematicBody2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("move","rel_vec"),&KinematicBody2D::move); - ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to); - ObjectTypeDB::bind_method(_MD("move_and_slide","linear_velocity","floor_normal","slope_stop_min_velocity","max_bounces"),&KinematicBody2D::move_and_slide,DEFVAL(Vector2(0,0)),DEFVAL(5),DEFVAL(4)); + ClassDB::bind_method(_MD("move","rel_vec"),&KinematicBody2D::move); + ClassDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to); + ClassDB::bind_method(_MD("move_and_slide","linear_velocity","floor_normal","slope_stop_min_velocity","max_bounces"),&KinematicBody2D::move_and_slide,DEFVAL(Vector2(0,0)),DEFVAL(5),DEFVAL(4)); - ObjectTypeDB::bind_method(_MD("test_move","from","rel_vec"),&KinematicBody2D::test_move); - ObjectTypeDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel); - ObjectTypeDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion); + ClassDB::bind_method(_MD("test_move","from","rel_vec"),&KinematicBody2D::test_move); + ClassDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel); + ClassDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion); - ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding); + ClassDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding); - ObjectTypeDB::bind_method(_MD("get_collision_pos"),&KinematicBody2D::get_collision_pos); - ObjectTypeDB::bind_method(_MD("get_collision_normal"),&KinematicBody2D::get_collision_normal); - ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity); - ObjectTypeDB::bind_method(_MD("get_collider:Variant"),&KinematicBody2D::_get_collider); - ObjectTypeDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape); - ObjectTypeDB::bind_method(_MD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata); - ObjectTypeDB::bind_method(_MD("get_move_and_slide_colliders"),&KinematicBody2D::get_move_and_slide_colliders); - ObjectTypeDB::bind_method(_MD("is_move_and_slide_on_floor"),&KinematicBody2D::is_move_and_slide_on_floor); - ObjectTypeDB::bind_method(_MD("is_move_and_slide_on_ceiling"),&KinematicBody2D::is_move_and_slide_on_ceiling); - ObjectTypeDB::bind_method(_MD("is_move_and_slide_on_wall"),&KinematicBody2D::is_move_and_slide_on_wall); + ClassDB::bind_method(_MD("get_collision_pos"),&KinematicBody2D::get_collision_pos); + ClassDB::bind_method(_MD("get_collision_normal"),&KinematicBody2D::get_collision_normal); + ClassDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity); + ClassDB::bind_method(_MD("get_collider:Variant"),&KinematicBody2D::_get_collider); + ClassDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape); + ClassDB::bind_method(_MD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata); + ClassDB::bind_method(_MD("get_move_and_slide_colliders"),&KinematicBody2D::get_move_and_slide_colliders); + ClassDB::bind_method(_MD("is_move_and_slide_on_floor"),&KinematicBody2D::is_move_and_slide_on_floor); + ClassDB::bind_method(_MD("is_move_and_slide_on_ceiling"),&KinematicBody2D::is_move_and_slide_on_ceiling); + ClassDB::bind_method(_MD("is_move_and_slide_on_wall"),&KinematicBody2D::is_move_and_slide_on_wall); - ObjectTypeDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin); - ObjectTypeDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin); + ClassDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin); + ClassDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin); ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/margin",PROPERTY_HINT_RANGE,"0.001,256,0.001"),_SCS("set_collision_margin"),_SCS("get_collision_margin")); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index ea29d873bd..5b7db35fe8 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -36,7 +36,7 @@ class PhysicsBody2D : public CollisionObject2D { - OBJ_TYPE(PhysicsBody2D,CollisionObject2D); + GDCLASS(PhysicsBody2D,CollisionObject2D); uint32_t mask; uint32_t collision_mask; @@ -55,8 +55,8 @@ protected: static void _bind_methods(); public: - void set_layer_mask(uint32_t p_mask); - uint32_t get_layer_mask() const; + void set_collision_layer(uint32_t p_mask); + uint32_t get_collision_layer() const; void set_collision_mask(uint32_t p_mask); uint32_t get_collision_mask() const; @@ -65,8 +65,8 @@ public: void set_collision_mask_bit(int p_bit, bool p_value); bool get_collision_mask_bit(int p_bit) const; - void set_layer_mask_bit(int p_bit, bool p_value); - bool get_layer_mask_bit(int p_bit) const; + void set_collision_layer_bit(int p_bit, bool p_value); + bool get_collision_layer_bit(int p_bit) const; void add_collision_exception_with(Node* p_node); //must be physicsbody void remove_collision_exception_with(Node* p_node); @@ -83,7 +83,7 @@ public: class StaticBody2D : public PhysicsBody2D { - OBJ_TYPE(StaticBody2D,PhysicsBody2D); + GDCLASS(StaticBody2D,PhysicsBody2D); Vector2 constant_linear_velocity; real_t constant_angular_velocity; @@ -118,7 +118,7 @@ public: class RigidBody2D : public PhysicsBody2D { - OBJ_TYPE(RigidBody2D,PhysicsBody2D); + GDCLASS(RigidBody2D,PhysicsBody2D); public: enum Mode { @@ -290,7 +290,7 @@ VARIANT_ENUM_CAST(RigidBody2D::CCDMode); class KinematicBody2D : public PhysicsBody2D { - OBJ_TYPE(KinematicBody2D,PhysicsBody2D); + GDCLASS(KinematicBody2D,PhysicsBody2D); float margin; bool colliding; @@ -319,7 +319,7 @@ public: Vector2 move(const Vector2& p_motion); Vector2 move_to(const Vector2& p_position); - bool test_move(const Matrix32 &p_from, const Vector2& p_motion); + bool test_move(const Transform2D &p_from, const Vector2& p_motion); bool is_colliding() const; Vector2 get_travel() const; diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 12893524d1..30e22a8437 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ Rect2 Polygon2D::get_item_rect() const { if (rect_cache_dirty){ int l =polygon.size(); - DVector<Vector2>::Read r = polygon.read(); + PoolVector<Vector2>::Read r = polygon.read(); item_rect=Rect2(); for(int i=0;i<l;i++) { Vector2 pos = r[i] + offset; @@ -84,7 +84,7 @@ void Polygon2D::_notification(int p_what) { int len = points.size(); { - DVector<Vector2>::Read polyr =polygon.read(); + PoolVector<Vector2>::Read polyr =polygon.read(); for(int i=0;i<len;i++) { points[i]=polyr[i]+offset; } @@ -148,7 +148,7 @@ void Polygon2D::_notification(int p_what) { if (texture.is_valid()) { - Matrix32 texmat(tex_rot,tex_ofs); + Transform2D texmat(tex_rot,tex_ofs); texmat.scale(tex_scale); Size2 tex_size=Vector2(1,1); @@ -157,7 +157,7 @@ void Polygon2D::_notification(int p_what) { if (points.size()==uv.size()) { - DVector<Vector2>::Read uvr = uv.read(); + PoolVector<Vector2>::Read uvr = uv.read(); for(int i=0;i<len;i++) { uvs[i]=texmat.xform(uvr[i])/tex_size; @@ -176,7 +176,7 @@ void Polygon2D::_notification(int p_what) { int color_len=vertex_colors.size(); colors.resize(len); { - DVector<Color>::Read color_r=vertex_colors.read(); + PoolVector<Color>::Read color_r=vertex_colors.read(); for(int i=0;i<color_len && i<len;i++){ colors[i]=color_r[i]; } @@ -194,25 +194,25 @@ void Polygon2D::_notification(int p_what) { } -void Polygon2D::set_polygon(const DVector<Vector2>& p_polygon) { +void Polygon2D::set_polygon(const PoolVector<Vector2>& p_polygon) { polygon=p_polygon; rect_cache_dirty=true; update(); } -DVector<Vector2> Polygon2D::get_polygon() const{ +PoolVector<Vector2> Polygon2D::get_polygon() const{ return polygon; } -void Polygon2D::set_uv(const DVector<Vector2>& p_uv) { +void Polygon2D::set_uv(const PoolVector<Vector2>& p_uv) { uv=p_uv; update(); } -DVector<Vector2> Polygon2D::get_uv() const{ +PoolVector<Vector2> Polygon2D::get_uv() const{ return uv; } @@ -227,12 +227,12 @@ Color Polygon2D::get_color() const{ return color; } -void Polygon2D::set_vertex_colors(const DVector<Color>& p_colors){ +void Polygon2D::set_vertex_colors(const PoolVector<Color>& p_colors){ vertex_colors=p_colors; update(); } -DVector<Color> Polygon2D::get_vertex_colors() const{ +PoolVector<Color> Polygon2D::get_vertex_colors() const{ return vertex_colors; } @@ -333,56 +333,60 @@ Vector2 Polygon2D::get_offset() const { void Polygon2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&Polygon2D::set_polygon); - ObjectTypeDB::bind_method(_MD("get_polygon"),&Polygon2D::get_polygon); + ClassDB::bind_method(_MD("set_polygon","polygon"),&Polygon2D::set_polygon); + ClassDB::bind_method(_MD("get_polygon"),&Polygon2D::get_polygon); - ObjectTypeDB::bind_method(_MD("set_uv","uv"),&Polygon2D::set_uv); - ObjectTypeDB::bind_method(_MD("get_uv"),&Polygon2D::get_uv); + ClassDB::bind_method(_MD("set_uv","uv"),&Polygon2D::set_uv); + ClassDB::bind_method(_MD("get_uv"),&Polygon2D::get_uv); - ObjectTypeDB::bind_method(_MD("set_color","color"),&Polygon2D::set_color); - ObjectTypeDB::bind_method(_MD("get_color"),&Polygon2D::get_color); + ClassDB::bind_method(_MD("set_color","color"),&Polygon2D::set_color); + ClassDB::bind_method(_MD("get_color"),&Polygon2D::get_color); - ObjectTypeDB::bind_method(_MD("set_vertex_colors","vertex_colors"),&Polygon2D::set_vertex_colors); - ObjectTypeDB::bind_method(_MD("get_vertex_colors"),&Polygon2D::get_vertex_colors); + ClassDB::bind_method(_MD("set_vertex_colors","vertex_colors"),&Polygon2D::set_vertex_colors); + ClassDB::bind_method(_MD("get_vertex_colors"),&Polygon2D::get_vertex_colors); - ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Polygon2D::set_texture); - ObjectTypeDB::bind_method(_MD("get_texture"),&Polygon2D::get_texture); + ClassDB::bind_method(_MD("set_texture","texture"),&Polygon2D::set_texture); + ClassDB::bind_method(_MD("get_texture"),&Polygon2D::get_texture); - ObjectTypeDB::bind_method(_MD("set_texture_offset","texture_offset"),&Polygon2D::set_texture_offset); - ObjectTypeDB::bind_method(_MD("get_texture_offset"),&Polygon2D::get_texture_offset); + ClassDB::bind_method(_MD("set_texture_offset","texture_offset"),&Polygon2D::set_texture_offset); + ClassDB::bind_method(_MD("get_texture_offset"),&Polygon2D::get_texture_offset); - ObjectTypeDB::bind_method(_MD("set_texture_rotation","texture_rotation"),&Polygon2D::set_texture_rotation); - ObjectTypeDB::bind_method(_MD("get_texture_rotation"),&Polygon2D::get_texture_rotation); + ClassDB::bind_method(_MD("set_texture_rotation","texture_rotation"),&Polygon2D::set_texture_rotation); + ClassDB::bind_method(_MD("get_texture_rotation"),&Polygon2D::get_texture_rotation); - ObjectTypeDB::bind_method(_MD("_set_texture_rotationd","texture_rotation"),&Polygon2D::_set_texture_rotationd); - ObjectTypeDB::bind_method(_MD("_get_texture_rotationd"),&Polygon2D::_get_texture_rotationd); + ClassDB::bind_method(_MD("_set_texture_rotationd","texture_rotation"),&Polygon2D::_set_texture_rotationd); + ClassDB::bind_method(_MD("_get_texture_rotationd"),&Polygon2D::_get_texture_rotationd); - ObjectTypeDB::bind_method(_MD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale); - ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Polygon2D::get_texture_scale); + ClassDB::bind_method(_MD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale); + ClassDB::bind_method(_MD("get_texture_scale"),&Polygon2D::get_texture_scale); - ObjectTypeDB::bind_method(_MD("set_invert","invert"),&Polygon2D::set_invert); - ObjectTypeDB::bind_method(_MD("get_invert"),&Polygon2D::get_invert); + ClassDB::bind_method(_MD("set_invert","invert"),&Polygon2D::set_invert); + ClassDB::bind_method(_MD("get_invert"),&Polygon2D::get_invert); - ObjectTypeDB::bind_method(_MD("set_invert_border","invert_border"),&Polygon2D::set_invert_border); - ObjectTypeDB::bind_method(_MD("get_invert_border"),&Polygon2D::get_invert_border); + ClassDB::bind_method(_MD("set_invert_border","invert_border"),&Polygon2D::set_invert_border); + ClassDB::bind_method(_MD("get_invert_border"),&Polygon2D::get_invert_border); - ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Polygon2D::set_offset); - ObjectTypeDB::bind_method(_MD("get_offset"),&Polygon2D::get_offset); + ClassDB::bind_method(_MD("set_offset","offset"),&Polygon2D::set_offset); + ClassDB::bind_method(_MD("get_offset"),&Polygon2D::get_offset); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv")); ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color")); - ADD_PROPERTY( PropertyInfo(Variant::COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset")); - ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture/offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture/scale"),_SCS("set_texture_scale"),_SCS("get_texture_scale")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"texture/rotation",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_texture_rotationd"),_SCS("_get_texture_rotationd")); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"invert/enable"),_SCS("set_invert"),_SCS("get_invert")); - ADD_PROPERTY( PropertyInfo(Variant::REAL,"invert/border",PROPERTY_HINT_RANGE,"0.1,16384,0.1"),_SCS("set_invert_border"),_SCS("get_invert_border")); + ADD_GROUP("Texture",""); + ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); + ADD_GROUP("Texture","texture_"); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset")); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture_scale"),_SCS("set_texture_scale"),_SCS("get_texture_scale")); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"texture_rotation",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_texture_rotationd"),_SCS("_get_texture_rotationd")); + + ADD_GROUP("Invert","invert_"); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"invert_enable"),_SCS("set_invert"),_SCS("get_invert")); + ADD_PROPERTY( PropertyInfo(Variant::REAL,"invert_border",PROPERTY_HINT_RANGE,"0.1,16384,0.1"),_SCS("set_invert_border"),_SCS("get_invert_border")); } diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index cecb9081f7..8434dae40c 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,11 +33,11 @@ class Polygon2D : public Node2D { - OBJ_TYPE(Polygon2D,Node2D); + GDCLASS(Polygon2D,Node2D); - DVector<Vector2> polygon; - DVector<Vector2> uv; - DVector<Color> vertex_colors; + PoolVector<Vector2> polygon; + PoolVector<Vector2> uv; + PoolVector<Color> vertex_colors; Color color; Ref<Texture> texture; Size2 tex_scale; @@ -60,17 +60,17 @@ protected: static void _bind_methods(); public: - void set_polygon(const DVector<Vector2>& p_polygon); - DVector<Vector2> get_polygon() const; + void set_polygon(const PoolVector<Vector2>& p_polygon); + PoolVector<Vector2> get_polygon() const; - void set_uv(const DVector<Vector2>& p_uv); - DVector<Vector2> get_uv() const; + void set_uv(const PoolVector<Vector2>& p_uv); + PoolVector<Vector2> get_uv() const; void set_color(const Color& p_color); Color get_color() const; - void set_vertex_colors(const DVector<Color>& p_colors); - DVector<Color> get_vertex_colors() const; + void set_vertex_colors(const PoolVector<Color>& p_colors); + PoolVector<Color> get_vertex_colors() const; void set_texture(const Ref<Texture>& p_texture); Ref<Texture> get_texture() const; diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp index c293305cb2..a25be18cb9 100644 --- a/scene/2d/position_2d.cpp +++ b/scene/2d/position_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h index 23821e62d4..fb68c265b3 100644 --- a/scene/2d/position_2d.h +++ b/scene/2d/position_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class Position2D : public Node2D { - OBJ_TYPE(Position2D,Node2D) + GDCLASS(Position2D,Node2D) void _draw_cross(); protected: diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index bd7f4faae5..14dfc10d9f 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -161,7 +161,7 @@ void RayCast2D::_notification(int p_what) { if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) break; - Matrix32 xf; + Transform2D xf; xf.rotate(cast_to.angle()); xf.translate(Vector2(0,cast_to.length())); @@ -201,7 +201,7 @@ void RayCast2D::_update_raycast_state() { Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space()); ERR_FAIL_COND( !dss ); - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Vector2 to = cast_to; if (to==Vector2()) @@ -263,41 +263,41 @@ void RayCast2D::clear_exceptions(){ void RayCast2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&RayCast2D::set_enabled); - ObjectTypeDB::bind_method(_MD("is_enabled"),&RayCast2D::is_enabled); + ClassDB::bind_method(_MD("set_enabled","enabled"),&RayCast2D::set_enabled); + ClassDB::bind_method(_MD("is_enabled"),&RayCast2D::is_enabled); - ObjectTypeDB::bind_method(_MD("set_cast_to","local_point"),&RayCast2D::set_cast_to); - ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to); + ClassDB::bind_method(_MD("set_cast_to","local_point"),&RayCast2D::set_cast_to); + ClassDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to); - ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding); - ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update); + ClassDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding); + ClassDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update); - ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider); - ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape); - ObjectTypeDB::bind_method(_MD("get_collision_point"),&RayCast2D::get_collision_point); - ObjectTypeDB::bind_method(_MD("get_collision_normal"),&RayCast2D::get_collision_normal); + ClassDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider); + ClassDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape); + ClassDB::bind_method(_MD("get_collision_point"),&RayCast2D::get_collision_point); + ClassDB::bind_method(_MD("get_collision_normal"),&RayCast2D::get_collision_normal); - ObjectTypeDB::bind_method(_MD("add_exception_rid","rid"),&RayCast2D::add_exception_rid); - ObjectTypeDB::bind_method(_MD("add_exception","node"),&RayCast2D::add_exception); + ClassDB::bind_method(_MD("add_exception_rid","rid"),&RayCast2D::add_exception_rid); + ClassDB::bind_method(_MD("add_exception","node"),&RayCast2D::add_exception); - ObjectTypeDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast2D::remove_exception_rid); - ObjectTypeDB::bind_method(_MD("remove_exception","node"),&RayCast2D::remove_exception); + ClassDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast2D::remove_exception_rid); + ClassDB::bind_method(_MD("remove_exception","node"),&RayCast2D::remove_exception); - ObjectTypeDB::bind_method(_MD("clear_exceptions"),&RayCast2D::clear_exceptions); + ClassDB::bind_method(_MD("clear_exceptions"),&RayCast2D::clear_exceptions); - ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&RayCast2D::set_layer_mask); - ObjectTypeDB::bind_method(_MD("get_layer_mask"),&RayCast2D::get_layer_mask); + ClassDB::bind_method(_MD("set_layer_mask","mask"),&RayCast2D::set_layer_mask); + ClassDB::bind_method(_MD("get_layer_mask"),&RayCast2D::get_layer_mask); - ObjectTypeDB::bind_method(_MD("set_type_mask","mask"),&RayCast2D::set_type_mask); - ObjectTypeDB::bind_method(_MD("get_type_mask"),&RayCast2D::get_type_mask); + ClassDB::bind_method(_MD("set_type_mask","mask"),&RayCast2D::set_type_mask); + ClassDB::bind_method(_MD("get_type_mask"),&RayCast2D::get_type_mask); - ObjectTypeDB::bind_method(_MD("set_exclude_parent_body","mask"),&RayCast2D::set_exclude_parent_body); - ObjectTypeDB::bind_method(_MD("get_exclude_parent_body"),&RayCast2D::get_exclude_parent_body); + ClassDB::bind_method(_MD("set_exclude_parent_body","mask"),&RayCast2D::set_exclude_parent_body); + ClassDB::bind_method(_MD("get_exclude_parent_body"),&RayCast2D::get_exclude_parent_body); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled")); ADD_PROPERTY(PropertyInfo(Variant::BOOL,"exclude_parent"),_SCS("set_exclude_parent_body"),_SCS("get_exclude_parent_body")); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to")); - ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask")); } diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index 9bdcc2e199..3e7a39ffde 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -33,7 +33,7 @@ class RayCast2D : public Node2D { - OBJ_TYPE(RayCast2D,Node2D); + GDCLASS(RayCast2D,Node2D); bool enabled; diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp index 4de648a1db..77f1a9d500 100644 --- a/scene/2d/remote_transform_2d.cpp +++ b/scene/2d/remote_transform_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -118,8 +118,8 @@ String RemoteTransform2D::get_configuration_warning() const { void RemoteTransform2D::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform2D::set_remote_node); - ObjectTypeDB::bind_method(_MD("get_remote_node"),&RemoteTransform2D::get_remote_node); + ClassDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform2D::set_remote_node); + ClassDB::bind_method(_MD("get_remote_node"),&RemoteTransform2D::get_remote_node); ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),_SCS("set_remote_node"),_SCS("get_remote_node")); } @@ -127,7 +127,7 @@ void RemoteTransform2D::_bind_methods() { RemoteTransform2D::RemoteTransform2D() { cache=0; - + set_notify_transform(true); } diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h index 0ea1438f0a..52c28ffd4f 100644 --- a/scene/2d/remote_transform_2d.h +++ b/scene/2d/remote_transform_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -30,7 +30,7 @@ class RemoteTransform2D : public Node2D { - OBJ_TYPE(RemoteTransform2D,Node2D); + GDCLASS(RemoteTransform2D,Node2D); NodePath remote_node; diff --git a/scene/2d/sample_player_2d.cpp b/scene/2d/sample_player_2d.cpp deleted file mode 100644 index 7c997b3f12..0000000000 --- a/scene/2d/sample_player_2d.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/*************************************************************************/ -/* sample_player_2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 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 "sample_player_2d.h" - -#include "servers/audio_server.h" -#include "servers/audio_server.h" -#include "servers/spatial_sound_server.h" - - -bool SamplePlayer2D::_set(const StringName& p_name, const Variant& p_value) { - - String name=p_name; - - if (name=="play/play") { - if (library.is_valid()) { - - String what=p_value; - if (what=="") - stop_all(); - else - play(what); - - played_back=what; - } - } else - return false; - - return true; -} - -bool SamplePlayer2D::_get(const StringName& p_name,Variant &r_ret) const { - - - String name=p_name; - - if (name=="play/play") { - r_ret=played_back; - } else - return false; - - return true; -} - -void SamplePlayer2D::_get_property_list(List<PropertyInfo> *p_list) const { - - String en=""; - if (library.is_valid()) { - List<StringName> samples; - Ref<SampleLibrary> ncl=library; - ncl->get_sample_list(&samples); - for (List<StringName>::Element *E=samples.front();E;E=E->next()) { - - en+=","; - en+=E->get(); - } - } - - p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER)); -} - -void SamplePlayer2D::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - - SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony); - - - } break; - } - -} - -void SamplePlayer2D::set_sample_library(const Ref<SampleLibrary>& p_library) { - - library=p_library; - _change_notify(); - update_configuration_warning(); -} - -Ref<SampleLibrary> SamplePlayer2D::get_sample_library() const { - - return library; -} - -void SamplePlayer2D::set_polyphony(int p_voice_count) { - - ERR_FAIL_COND(p_voice_count<0 || p_voice_count>64); - polyphony=p_voice_count; - if (get_source_rid().is_valid()) - SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony); - -} - -int SamplePlayer2D::get_polyphony() const { - - return polyphony; -} - -SamplePlayer2D::VoiceID SamplePlayer2D::play(const String& p_sample,int p_voice) { - - if (!get_source_rid().is_valid()) - return INVALID_VOICE; - if (library.is_null()) - return INVALID_VOICE; - if (!library->has_sample(p_sample)) - return INVALID_VOICE; - Ref<Sample> sample = library->get_sample(p_sample); - float vol_change = library->sample_get_volume_db(p_sample); - float pitch_change = library->sample_get_pitch_scale(p_sample); - - VoiceID vid = SpatialSound2DServer::get_singleton()->source_play_sample(get_source_rid(),sample->get_rid(),sample->get_mix_rate()*pitch_change,p_voice); - if (vol_change) - SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),vid,vol_change); - - - if (random_pitch_scale) { - float ps = Math::random(-random_pitch_scale,random_pitch_scale); - if (ps>0) - ps=1.0+ps; - else - ps=1.0/(1.0-ps); - SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),vid,ps*pitch_change); - - } - - return vid; -} -//voices -void SamplePlayer2D::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale) { - - if (!get_source_rid().is_valid()) - return; - - SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),p_voice,p_pitch_scale); - -} - -void SamplePlayer2D::voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db) { - - if (!get_source_rid().is_valid()) - return; - SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),p_voice,p_volume_db); - -} - -bool SamplePlayer2D::is_voice_active(VoiceID p_voice) const { - - if (!get_source_rid().is_valid()) - return false; - return SpatialSound2DServer::get_singleton()->source_is_voice_active(get_source_rid(),p_voice); - -} - -void SamplePlayer2D::stop_voice(VoiceID p_voice) { - - if (!get_source_rid().is_valid()) - return; - SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),p_voice); - -} - -void SamplePlayer2D::stop_all() { - - if (!get_source_rid().is_valid()) - return; - - for(int i=0;i<polyphony;i++) { - - SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),i); - } -} - -void SamplePlayer2D::set_random_pitch_scale(float p_scale) { - random_pitch_scale=p_scale; -} - -float SamplePlayer2D::get_random_pitch_scale() const { - - return random_pitch_scale; -} - -String SamplePlayer2D::get_configuration_warning() const { - - if (library.is_null()) { - return TTR("A SampleLibrary resource must be created or set in the 'samples' property in order for SamplePlayer to play sound."); - } - - return String(); -} - -void SamplePlayer2D::_bind_methods() { - - - ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer2D::set_sample_library); - ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer2D::get_sample_library); - - ObjectTypeDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer2D::set_polyphony); - ObjectTypeDB::bind_method(_MD("get_polyphony"),&SamplePlayer2D::get_polyphony); - - ObjectTypeDB::bind_method(_MD("play","sample","voice"),&SamplePlayer2D::play,DEFVAL(NEXT_VOICE)); - //voices,DEV - ObjectTypeDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SamplePlayer2D::voice_set_pitch_scale); - ObjectTypeDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SamplePlayer2D::voice_set_volume_scale_db); - - ObjectTypeDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer2D::is_voice_active); - ObjectTypeDB::bind_method(_MD("stop_voice","voice"),&SamplePlayer2D::stop_voice); - ObjectTypeDB::bind_method(_MD("stop_all"),&SamplePlayer2D::stop_all); - - ObjectTypeDB::bind_method(_MD("set_random_pitch_scale","val"),&SamplePlayer2D::set_random_pitch_scale); - ObjectTypeDB::bind_method(_MD("get_random_pitch_scale"),&SamplePlayer2D::get_random_pitch_scale); - - BIND_CONSTANT( INVALID_VOICE ); - BIND_CONSTANT( NEXT_VOICE ); - - ADD_PROPERTY( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony")); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library")); - ADD_PROPERTY( PropertyInfo( Variant::REAL, "config/pitch_random", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_random_pitch_scale"),_SCS("get_random_pitch_scale")); - - -} - - -SamplePlayer2D::SamplePlayer2D() { - - polyphony=1; - random_pitch_scale=0; - -} - -SamplePlayer2D::~SamplePlayer2D() { - - -} diff --git a/scene/2d/sample_player_2d.h b/scene/2d/sample_player_2d.h deleted file mode 100644 index 5ab7f024d3..0000000000 --- a/scene/2d/sample_player_2d.h +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************/ -/* sample_player_2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 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 SAMPLE_PLAYER_2D_H -#define SAMPLE_PLAYER_2D_H - -#include "scene/2d/sound_player_2d.h" -#include "scene/resources/sample_library.h" - -class SamplePlayer2D : public SoundPlayer2D { - - OBJ_TYPE(SamplePlayer2D,SoundPlayer2D); -public: - - enum { - - INVALID_VOICE=SpatialSoundServer::SOURCE_INVALID_VOICE, - NEXT_VOICE=SpatialSoundServer::SOURCE_NEXT_VOICE - }; - - typedef int VoiceID; - - -private: - - Ref<SampleLibrary> library; - int polyphony; - String played_back; - float random_pitch_scale; - -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 _notification(int p_what); - - static void _bind_methods(); - -public: - - void set_sample_library(const Ref<SampleLibrary>& p_library); - Ref<SampleLibrary> get_sample_library() const; - - void set_polyphony(int p_voice_count); - int get_polyphony() const; - - VoiceID play(const String& p_sample,int p_voice=NEXT_VOICE); - //voices - void voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale); - void voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db); - - bool is_voice_active(VoiceID p_voice) const; - void stop_voice(VoiceID p_voice); - void stop_all(); - - void set_random_pitch_scale(float p_scale); - float get_random_pitch_scale() const; - - String get_configuration_warning() const; - - SamplePlayer2D(); - ~SamplePlayer2D(); - - -}; - -#endif // SAMPLE_PLAYER_2D_H diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index fac94f19dc..20db63b66f 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -236,7 +236,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (p_event.screen_touch.pressed) { - if (!is_visible()) + if (!is_visible_in_tree()) return; if (finger_pressed!=-1) @@ -307,8 +307,10 @@ Rect2 TouchScreenButton::get_item_rect() const { if (texture.is_null()) return Rect2(0,0,1,1); - //if (texture.is_null()) - // return CanvasItem::get_item_rect(); + /* + if (texture.is_null()) + return CanvasItem::get_item_rect(); + */ return Rect2(Size2(),texture->get_size()); } @@ -338,27 +340,27 @@ bool TouchScreenButton::is_passby_press_enabled() const{ void TouchScreenButton::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_texture","texture"),&TouchScreenButton::set_texture); - ObjectTypeDB::bind_method(_MD("get_texture"),&TouchScreenButton::get_texture); + ClassDB::bind_method(_MD("set_texture","texture"),&TouchScreenButton::set_texture); + ClassDB::bind_method(_MD("get_texture"),&TouchScreenButton::get_texture); - ObjectTypeDB::bind_method(_MD("set_texture_pressed","texture_pressed"),&TouchScreenButton::set_texture_pressed); - ObjectTypeDB::bind_method(_MD("get_texture_pressed"),&TouchScreenButton::get_texture_pressed); + ClassDB::bind_method(_MD("set_texture_pressed","texture_pressed"),&TouchScreenButton::set_texture_pressed); + ClassDB::bind_method(_MD("get_texture_pressed"),&TouchScreenButton::get_texture_pressed); - ObjectTypeDB::bind_method(_MD("set_bitmask","bitmask"),&TouchScreenButton::set_bitmask); - ObjectTypeDB::bind_method(_MD("get_bitmask"),&TouchScreenButton::get_bitmask); + ClassDB::bind_method(_MD("set_bitmask","bitmask"),&TouchScreenButton::set_bitmask); + ClassDB::bind_method(_MD("get_bitmask"),&TouchScreenButton::get_bitmask); - ObjectTypeDB::bind_method(_MD("set_action","action"),&TouchScreenButton::set_action); - ObjectTypeDB::bind_method(_MD("get_action"),&TouchScreenButton::get_action); + ClassDB::bind_method(_MD("set_action","action"),&TouchScreenButton::set_action); + ClassDB::bind_method(_MD("get_action"),&TouchScreenButton::get_action); - ObjectTypeDB::bind_method(_MD("set_visibility_mode","mode"),&TouchScreenButton::set_visibility_mode); - ObjectTypeDB::bind_method(_MD("get_visibility_mode"),&TouchScreenButton::get_visibility_mode); + ClassDB::bind_method(_MD("set_visibility_mode","mode"),&TouchScreenButton::set_visibility_mode); + ClassDB::bind_method(_MD("get_visibility_mode"),&TouchScreenButton::get_visibility_mode); - ObjectTypeDB::bind_method(_MD("set_passby_press","enabled"),&TouchScreenButton::set_passby_press); - ObjectTypeDB::bind_method(_MD("is_passby_press_enabled"),&TouchScreenButton::is_passby_press_enabled); + ClassDB::bind_method(_MD("set_passby_press","enabled"),&TouchScreenButton::set_passby_press); + ClassDB::bind_method(_MD("is_passby_press_enabled"),&TouchScreenButton::is_passby_press_enabled); - ObjectTypeDB::bind_method(_MD("is_pressed"),&TouchScreenButton::is_pressed); + ClassDB::bind_method(_MD("is_pressed"),&TouchScreenButton::is_pressed); - ObjectTypeDB::bind_method(_MD("_input"),&TouchScreenButton::_input); + ClassDB::bind_method(_MD("_input"),&TouchScreenButton::_input); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture_pressed"),_SCS("get_texture_pressed")); diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h index ff3b50bf5e..34e02d644b 100644 --- a/scene/2d/screen_button.h +++ b/scene/2d/screen_button.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class TouchScreenButton : public Node2D { - OBJ_TYPE(TouchScreenButton,Node2D); + GDCLASS(TouchScreenButton,Node2D); public: enum VisibilityMode { diff --git a/scene/2d/sound_player_2d.cpp b/scene/2d/sound_player_2d.cpp deleted file mode 100644 index 41ce87faf9..0000000000 --- a/scene/2d/sound_player_2d.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************/ -/* sound_player_2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 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 "sound_player_2d.h" - -#include "servers/audio_server.h" - -#include "servers/spatial_sound_2d_server.h" -#include "scene/resources/surface_tool.h" - - -void SoundPlayer2D::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - //find the sound space - - source_rid = SpatialSound2DServer::get_singleton()->source_create(get_world_2d()->get_sound_space()); - - for(int i=0;i<PARAM_MAX;i++) - set_param(Param(i),params[i]); - - SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform()); - - - } break; - case NOTIFICATION_TRANSFORM_CHANGED: { - - SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform()); - - } break; - case NOTIFICATION_EXIT_TREE: { - - if (source_rid.is_valid()) - SpatialSound2DServer::get_singleton()->free(source_rid); - - } break; - } - -} - - -void SoundPlayer2D::set_param( Param p_param, float p_value) { - - ERR_FAIL_INDEX(p_param,PARAM_MAX); - params[p_param]=p_value; - if (source_rid.is_valid()) - SpatialSound2DServer::get_singleton()->source_set_param(source_rid,(SpatialSound2DServer::SourceParam)p_param,p_value); - -} - -float SoundPlayer2D::get_param( Param p_param) const { - - ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0); - return params[p_param]; - -} - - -void SoundPlayer2D::_bind_methods() { - - - ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SoundPlayer2D::set_param); - ObjectTypeDB::bind_method(_MD("get_param","param"),&SoundPlayer2D::get_param); - - BIND_CONSTANT( PARAM_VOLUME_DB ); - BIND_CONSTANT( PARAM_PITCH_SCALE ); - BIND_CONSTANT( PARAM_ATTENUATION_MIN_DISTANCE ); - BIND_CONSTANT( PARAM_ATTENUATION_MAX_DISTANCE ); - BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP ); - BIND_CONSTANT( PARAM_MAX ); - - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/min_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/max_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE); - ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP); - -} - - -SoundPlayer2D::SoundPlayer2D() { - - params[PARAM_VOLUME_DB]=0.0; - params[PARAM_PITCH_SCALE]=1.0; - params[PARAM_ATTENUATION_MIN_DISTANCE]=1; - params[PARAM_ATTENUATION_MAX_DISTANCE]=2048; - params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good) - - -} - -SoundPlayer2D::~SoundPlayer2D() { - - -} diff --git a/scene/2d/sound_player_2d.h b/scene/2d/sound_player_2d.h deleted file mode 100644 index 0e75887235..0000000000 --- a/scene/2d/sound_player_2d.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************/ -/* sound_player_2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 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 SOUND_PLAYER_2D_H -#define SOUND_PLAYER_2D_H - - -#include "scene/2d/node_2d.h" -#include "scene/resources/sample_library.h" -#include "servers/spatial_sound_2d_server.h" -#include "scene/main/viewport.h" - -class SoundPlayer2D : public Node2D { - - OBJ_TYPE(SoundPlayer2D,Node2D); -public: - - - enum Param { - - PARAM_VOLUME_DB=SpatialSound2DServer::SOURCE_PARAM_VOLUME_DB, - PARAM_PITCH_SCALE=SpatialSound2DServer::SOURCE_PARAM_PITCH_SCALE, - PARAM_ATTENUATION_MIN_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE, - PARAM_ATTENUATION_MAX_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE, - PARAM_ATTENUATION_DISTANCE_EXP=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP, - PARAM_MAX=SpatialSound2DServer::SOURCE_PARAM_MAX - }; - -private: - - float params[PARAM_MAX]; - RID source_rid; - - -protected: - - _FORCE_INLINE_ RID get_source_rid() const { return source_rid; } - - void _notification(int p_what); - - static void _bind_methods(); - -public: - - void set_param( Param p_param, float p_value); - float get_param( Param p_param) const; - - - SoundPlayer2D(); - ~SoundPlayer2D(); - - -}; - -VARIANT_ENUM_CAST(SoundPlayer2D::Param ); - -#endif // SOUND_PLAYER_2D_H diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index 8723db95d6..bea45aae4e 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -86,7 +86,7 @@ void Sprite::_notification(int p_what) { Point2 ofs=offset; if (centered) ofs-=s/2; - if (OS::get_singleton()->get_use_pixel_snap()) { + if (Engine::get_singleton()->get_use_pixel_snap()) { ofs=ofs.floor(); } @@ -97,7 +97,7 @@ void Sprite::_notification(int p_what) { if (vflip) dst_rect.size.y=-dst_rect.size.y; - texture->draw_rect_region(ci,dst_rect,src_rect,modulate); + texture->draw_rect_region(ci,dst_rect,src_rect); } break; } @@ -249,24 +249,16 @@ int Sprite::get_hframes() const { return hframes; } -void Sprite::set_modulate(const Color& p_color) { - - modulate=p_color; - update(); -} - -Color Sprite::get_modulate() const{ - - return modulate; -} Rect2 Sprite::get_item_rect() const { if (texture.is_null()) return Rect2(0,0,1,1); - //if (texture.is_null()) - // return CanvasItem::get_item_rect(); + /* + if (texture.is_null()) + return CanvasItem::get_item_rect(); + */ Size2i s; @@ -302,38 +294,35 @@ void Sprite::_validate_property(PropertyInfo& property) const { void Sprite::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture); - ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Sprite::get_texture); - - ObjectTypeDB::bind_method(_MD("set_centered","centered"),&Sprite::set_centered); - ObjectTypeDB::bind_method(_MD("is_centered"),&Sprite::is_centered); + ClassDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture); + ClassDB::bind_method(_MD("get_texture:Texture"),&Sprite::get_texture); - ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Sprite::set_offset); - ObjectTypeDB::bind_method(_MD("get_offset"),&Sprite::get_offset); + ClassDB::bind_method(_MD("set_centered","centered"),&Sprite::set_centered); + ClassDB::bind_method(_MD("is_centered"),&Sprite::is_centered); - ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&Sprite::set_flip_h); - ObjectTypeDB::bind_method(_MD("is_flipped_h"),&Sprite::is_flipped_h); + ClassDB::bind_method(_MD("set_offset","offset"),&Sprite::set_offset); + ClassDB::bind_method(_MD("get_offset"),&Sprite::get_offset); - ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&Sprite::set_flip_v); - ObjectTypeDB::bind_method(_MD("is_flipped_v"),&Sprite::is_flipped_v); + ClassDB::bind_method(_MD("set_flip_h","flip_h"),&Sprite::set_flip_h); + ClassDB::bind_method(_MD("is_flipped_h"),&Sprite::is_flipped_h); - ObjectTypeDB::bind_method(_MD("set_region","enabled"),&Sprite::set_region); - ObjectTypeDB::bind_method(_MD("is_region"),&Sprite::is_region); + ClassDB::bind_method(_MD("set_flip_v","flip_v"),&Sprite::set_flip_v); + ClassDB::bind_method(_MD("is_flipped_v"),&Sprite::is_flipped_v); - ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Sprite::set_region_rect); - ObjectTypeDB::bind_method(_MD("get_region_rect"),&Sprite::get_region_rect); + ClassDB::bind_method(_MD("set_region","enabled"),&Sprite::set_region); + ClassDB::bind_method(_MD("is_region"),&Sprite::is_region); - ObjectTypeDB::bind_method(_MD("set_frame","frame"),&Sprite::set_frame); - ObjectTypeDB::bind_method(_MD("get_frame"),&Sprite::get_frame); + ClassDB::bind_method(_MD("set_region_rect","rect"),&Sprite::set_region_rect); + ClassDB::bind_method(_MD("get_region_rect"),&Sprite::get_region_rect); - ObjectTypeDB::bind_method(_MD("set_vframes","vframes"),&Sprite::set_vframes); - ObjectTypeDB::bind_method(_MD("get_vframes"),&Sprite::get_vframes); + ClassDB::bind_method(_MD("set_frame","frame"),&Sprite::set_frame); + ClassDB::bind_method(_MD("get_frame"),&Sprite::get_frame); - ObjectTypeDB::bind_method(_MD("set_hframes","hframes"),&Sprite::set_hframes); - ObjectTypeDB::bind_method(_MD("get_hframes"),&Sprite::get_hframes); + ClassDB::bind_method(_MD("set_vframes","vframes"),&Sprite::set_vframes); + ClassDB::bind_method(_MD("get_vframes"),&Sprite::get_vframes); - ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&Sprite::set_modulate); - ObjectTypeDB::bind_method(_MD("get_modulate"),&Sprite::get_modulate); + ClassDB::bind_method(_MD("set_hframes","hframes"),&Sprite::set_hframes); + ClassDB::bind_method(_MD("get_hframes"),&Sprite::get_hframes); ADD_SIGNAL(MethodInfo("frame_changed")); ADD_SIGNAL(MethodInfo("texture_changed")); @@ -346,7 +335,6 @@ void Sprite::_bind_methods() { ADD_PROPERTYNO( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_vframes"),_SCS("get_vframes")); ADD_PROPERTYNO( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_hframes"),_SCS("get_hframes")); ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame")); - ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate")); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region")); ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect")); @@ -364,9 +352,6 @@ Sprite::Sprite() { vframes=1; hframes=1; - modulate=Color(1,1,1,1); - - } @@ -377,7 +362,7 @@ Sprite::Sprite() { /// /// - +#if 0 void ViewportSprite::edit_set_pivot(const Point2& p_pivot) { set_offset(p_pivot); @@ -527,8 +512,10 @@ Rect2 ViewportSprite::get_item_rect() const { if (texture.is_null()) return Rect2(0,0,1,1); - //if (texture.is_null()) - // return CanvasItem::get_item_rect(); + /* + if (texture.is_null()) + return CanvasItem::get_item_rect(); + */ Size2i s; @@ -565,17 +552,17 @@ String ViewportSprite::get_configuration_warning() const { void ViewportSprite::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_viewport_path","path"),&ViewportSprite::set_viewport_path); - ObjectTypeDB::bind_method(_MD("get_viewport_path"),&ViewportSprite::get_viewport_path); + ClassDB::bind_method(_MD("set_viewport_path","path"),&ViewportSprite::set_viewport_path); + ClassDB::bind_method(_MD("get_viewport_path"),&ViewportSprite::get_viewport_path); - ObjectTypeDB::bind_method(_MD("set_centered","centered"),&ViewportSprite::set_centered); - ObjectTypeDB::bind_method(_MD("is_centered"),&ViewportSprite::is_centered); + ClassDB::bind_method(_MD("set_centered","centered"),&ViewportSprite::set_centered); + ClassDB::bind_method(_MD("is_centered"),&ViewportSprite::is_centered); - ObjectTypeDB::bind_method(_MD("set_offset","offset"),&ViewportSprite::set_offset); - ObjectTypeDB::bind_method(_MD("get_offset"),&ViewportSprite::get_offset); + ClassDB::bind_method(_MD("set_offset","offset"),&ViewportSprite::set_offset); + ClassDB::bind_method(_MD("get_offset"),&ViewportSprite::get_offset); - ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&ViewportSprite::set_modulate); - ObjectTypeDB::bind_method(_MD("get_modulate"),&ViewportSprite::get_modulate); + ClassDB::bind_method(_MD("set_modulate","modulate"),&ViewportSprite::set_modulate); + ClassDB::bind_method(_MD("get_modulate"),&ViewportSprite::get_modulate); ADD_PROPERTYNZ( PropertyInfo( Variant::NODE_PATH, "viewport"), _SCS("set_viewport_path"),_SCS("get_viewport_path")); ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered")); @@ -589,3 +576,4 @@ ViewportSprite::ViewportSprite() { centered=true; modulate=Color(1,1,1,1); } +#endif diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index 32d3f476d1..ab4487ef7b 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -35,7 +35,7 @@ class Sprite : public Node2D { - OBJ_TYPE( Sprite, Node2D ); + GDCLASS( Sprite, Node2D ); Ref<Texture> texture; @@ -52,14 +52,13 @@ class Sprite : public Node2D { int vframes; int hframes; - Color modulate; protected: void _notification(int p_what); - static void _bind_methods();; + static void _bind_methods(); virtual void _validate_property(PropertyInfo& property) const; @@ -99,17 +98,15 @@ public: void set_hframes(int p_amount); int get_hframes() const; - void set_modulate(const Color& p_color); - Color get_modulate() const; - virtual Rect2 get_item_rect() const; Sprite(); }; +#if 0 class ViewportSprite : public Node2D { - OBJ_TYPE( ViewportSprite, Node2D ); + GDCLASS( ViewportSprite, Node2D ); Ref<Texture> texture; NodePath viewport_path; @@ -122,7 +119,7 @@ protected: void _notification(int p_what); - static void _bind_methods();; + static void _bind_methods(); public: @@ -149,4 +146,5 @@ public: ViewportSprite(); }; +#endif #endif // SPRITE_H diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index cc904e4d04..d6d713920c 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -114,16 +114,16 @@ void TileMap::_update_quadrant_transform() { if (!is_inside_tree()) return; - Matrix32 global_transform = get_global_transform(); + Transform2D global_transform = get_global_transform(); - Matrix32 nav_rel; + Transform2D nav_rel; if (navigation) nav_rel = get_relative_transform_to_parent(navigation); for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { Quadrant &q=E->get(); - Matrix32 xform; + Transform2D xform; xform.set_origin( q.pos ); xform = global_transform * xform; Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform); @@ -218,7 +218,7 @@ 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) { +void TileMap::_fix_cell_transform(Transform2D& xform,const Cell& p_cell, const Vector2& p_offset, const Size2 &p_sc) { Size2 s=p_sc; Vector2 offset = p_offset; @@ -268,16 +268,16 @@ void TileMap::_update_dirty_quadrants() { if (!pending_update) return; - if (!is_inside_tree()) - return; - if (!tile_set.is_valid()) + if (!is_inside_tree() || !tile_set.is_valid()) { + pending_update = false; return; + } VisualServer *vs = VisualServer::get_singleton(); Physics2DServer *ps = Physics2DServer::get_singleton(); Vector2 tofs = get_cell_draw_offset(); Vector2 tcenter = cell_size/2; - Matrix32 nav_rel; + Transform2D nav_rel; if (navigation) nav_rel = get_relative_transform_to_parent(navigation); @@ -348,11 +348,10 @@ void TileMap::_update_dirty_quadrants() { 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; + Transform2D xform; xform.set_origin( q.pos ); vs->canvas_item_set_transform( canvas_item, xform ); vs->canvas_item_set_light_mask(canvas_item,get_light_mask()); - vs->canvas_item_set_blend_mode(canvas_item,VS::MaterialBlendMode(get_blend_mode())); q.canvas_items.push_back(canvas_item); @@ -458,10 +457,11 @@ void TileMap::_update_dirty_quadrants() { } + Color modulate = tile_set->tile_get_modulate(c.id); if (r==Rect2()) { - tex->draw_rect(canvas_item,rect,false,Color(1,1,1),c.transpose); + tex->draw_rect(canvas_item,rect,false,modulate,c.transpose); } else { - tex->draw_rect_region(canvas_item,rect,r,Color(1,1,1),c.transpose); + tex->draw_rect_region(canvas_item,rect,r,modulate,c.transpose); } Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id); @@ -473,12 +473,12 @@ void TileMap::_update_dirty_quadrants() { if (shape.is_valid()) { Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id); - Matrix32 xform; + Transform2D xform; xform.set_origin(offset.floor()); _fix_cell_transform(xform,c,shape_ofs+center_ofs,s); - if (debug_canvas_item) { + if (debug_canvas_item.is_valid()) { vs->canvas_item_add_set_transform(debug_canvas_item,xform); shape->draw(debug_canvas_item,debug_collision_color); @@ -489,15 +489,15 @@ void TileMap::_update_dirty_quadrants() { } } - if (debug_canvas_item) { - vs->canvas_item_add_set_transform(debug_canvas_item,Matrix32()); + if (debug_canvas_item.is_valid()) { + vs->canvas_item_add_set_transform(debug_canvas_item,Transform2D()); } if (navigation) { Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id); if (navpoly.is_valid()) { Vector2 npoly_ofs = tile_set->tile_get_navigation_polygon_offset(c.id); - Matrix32 xform; + Transform2D xform; xform.set_origin(offset.floor()+q.pos); _fix_cell_transform(xform,c,npoly_ofs+center_ofs,s); @@ -516,7 +516,7 @@ void TileMap::_update_dirty_quadrants() { if (occluder.is_valid()) { Vector2 occluder_ofs = tile_set->tile_get_occluder_offset(c.id); - Matrix32 xform; + Transform2D xform; xform.set_origin(offset.floor()+q.pos); _fix_cell_transform(xform,c,occluder_ofs+center_ofs,s); @@ -542,26 +542,19 @@ void TileMap::_update_dirty_quadrants() { if (quadrant_order_dirty) { + int index=-0x80000000; //always must be drawn below children for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { Quadrant &q=E->get(); for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) { - VS::get_singleton()->canvas_item_raise(E->get()); + VS::get_singleton()->canvas_item_set_draw_index(E->get(),index++); } } quadrant_order_dirty=false; } - for(int i=0;i<get_child_count();i++) { - - CanvasItem *c=get_child(i)->cast_to<CanvasItem>(); - - if (c) - VS::get_singleton()->canvas_item_raise(c->get_canvas_item()); - } - _recompute_rect_cache(); } @@ -606,7 +599,7 @@ void TileMap::_recompute_rect_cache() { Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const PosKey& p_qk) { - Matrix32 xform; + Transform2D 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*_get_quadrant_size(),p_qk.y*_get_quadrant_size()); @@ -618,7 +611,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const xform.set_origin( q.pos ); -// q.canvas_item = VisualServer::get_singleton()->canvas_item_create(); + //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); @@ -827,10 +820,10 @@ void TileMap::clear() { tile_map.clear(); } -void TileMap::_set_tile_data(const DVector<int>& p_data) { +void TileMap::_set_tile_data(const PoolVector<int>& p_data) { int c=p_data.size(); - DVector<int>::Read r = p_data.read(); + PoolVector<int>::Read r = p_data.read(); for(int i=0;i<c;i+=2) { @@ -857,19 +850,21 @@ void TileMap::_set_tile_data(const DVector<int>& p_data) { bool transpose = v&(1<<31); v&=(1<<29)-1; -// if (x<-20 || y <-20 || x>4000 || y>4000) -// continue; + /* + if (x<-20 || y <-20 || x>4000 || y>4000) + continue; + */ set_cell(x,y,v,flip_h,flip_v,transpose); } } -DVector<int> TileMap::_get_tile_data() const { +PoolVector<int> TileMap::_get_tile_data() const { - DVector<int> data; + PoolVector<int> data; data.resize(tile_map.size()*2); - DVector<int>::Write w = data.write(); + PoolVector<int>::Write w = data.write(); int idx=0; for(const Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) { @@ -890,7 +885,7 @@ DVector<int> TileMap::_get_tile_data() const { } - w = DVector<int>::Write(); + w = PoolVector<int>::Write(); return data; @@ -1042,13 +1037,13 @@ TileMap::HalfOffset TileMap::get_half_offset() const { return half_offset; } -Matrix32 TileMap::get_cell_transform() const { +Transform2D TileMap::get_cell_transform() const { switch(mode) { case MODE_SQUARE: { - Matrix32 m; + Transform2D m; m[0]*=cell_size.x; m[1]*=cell_size.y; return m; @@ -1057,7 +1052,7 @@ Matrix32 TileMap::get_cell_transform() const { //isometric only makes sense when y is positive in both x and y vectors, otherwise //the drawing of tiles will overlap - Matrix32 m; + Transform2D m; m[0]=Vector2(cell_size.x*0.5,cell_size.y*0.5); m[1]=Vector2(-cell_size.x*0.5,cell_size.y*0.5); return m; @@ -1069,10 +1064,10 @@ Matrix32 TileMap::get_cell_transform() const { } break; } - return Matrix32(); + return Transform2D(); } -void TileMap::set_custom_transform(const Matrix32& p_xform) { +void TileMap::set_custom_transform(const Transform2D& p_xform) { _clear_quadrants(); custom_transform=p_xform; @@ -1081,7 +1076,7 @@ void TileMap::set_custom_transform(const Matrix32& p_xform) { } -Matrix32 TileMap::get_custom_transform() const{ +Transform2D TileMap::get_custom_transform() const{ return custom_transform; } @@ -1191,106 +1186,103 @@ void TileMap::set_light_mask(int p_light_mask) { } } -void TileMap::set_blend_mode(BlendMode p_blend_mode) { - - CanvasItem::set_blend_mode(p_blend_mode); - _recreate_quadrants(); - -} - - void TileMap::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_tileset","tileset:TileSet"),&TileMap::set_tileset); - ObjectTypeDB::bind_method(_MD("get_tileset:TileSet"),&TileMap::get_tileset); + ClassDB::bind_method(_MD("set_tileset","tileset:TileSet"),&TileMap::set_tileset); + ClassDB::bind_method(_MD("get_tileset:TileSet"),&TileMap::get_tileset); - ObjectTypeDB::bind_method(_MD("set_mode","mode"),&TileMap::set_mode); - ObjectTypeDB::bind_method(_MD("get_mode"),&TileMap::get_mode); + ClassDB::bind_method(_MD("set_mode","mode"),&TileMap::set_mode); + ClassDB::bind_method(_MD("get_mode"),&TileMap::get_mode); - ObjectTypeDB::bind_method(_MD("set_half_offset","half_offset"),&TileMap::set_half_offset); - ObjectTypeDB::bind_method(_MD("get_half_offset"),&TileMap::get_half_offset); + ClassDB::bind_method(_MD("set_half_offset","half_offset"),&TileMap::set_half_offset); + ClassDB::bind_method(_MD("get_half_offset"),&TileMap::get_half_offset); - ObjectTypeDB::bind_method(_MD("set_custom_transform","custom_transform"),&TileMap::set_custom_transform); - ObjectTypeDB::bind_method(_MD("get_custom_transform"),&TileMap::get_custom_transform); + ClassDB::bind_method(_MD("set_custom_transform","custom_transform"),&TileMap::set_custom_transform); + ClassDB::bind_method(_MD("get_custom_transform"),&TileMap::get_custom_transform); - ObjectTypeDB::bind_method(_MD("set_cell_size","size"),&TileMap::set_cell_size); - ObjectTypeDB::bind_method(_MD("get_cell_size"),&TileMap::get_cell_size); + ClassDB::bind_method(_MD("set_cell_size","size"),&TileMap::set_cell_size); + ClassDB::bind_method(_MD("get_cell_size"),&TileMap::get_cell_size); - ObjectTypeDB::bind_method(_MD("_set_old_cell_size","size"),&TileMap::_set_old_cell_size); - ObjectTypeDB::bind_method(_MD("_get_old_cell_size"),&TileMap::_get_old_cell_size); + ClassDB::bind_method(_MD("_set_old_cell_size","size"),&TileMap::_set_old_cell_size); + ClassDB::bind_method(_MD("_get_old_cell_size"),&TileMap::_get_old_cell_size); - ObjectTypeDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size); - ObjectTypeDB::bind_method(_MD("get_quadrant_size"),&TileMap::get_quadrant_size); + ClassDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size); + ClassDB::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); + ClassDB::bind_method(_MD("set_tile_origin","origin"),&TileMap::set_tile_origin); + ClassDB::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); + ClassDB::bind_method(_MD("set_center_x","enable"),&TileMap::set_center_x); + ClassDB::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); + ClassDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y); + ClassDB::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); + ClassDB::bind_method(_MD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode); + ClassDB::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); + ClassDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic); + ClassDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic); - ObjectTypeDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer); - ObjectTypeDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer); + ClassDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer); + ClassDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer); - ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask); - ObjectTypeDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask); + ClassDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask); + ClassDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask); - ObjectTypeDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction); - ObjectTypeDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction); + ClassDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction); + ClassDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction); - ObjectTypeDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce); - ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce); + ClassDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce); + ClassDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce); - ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask); - ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask); + ClassDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask); + ClassDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask); - ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell); - ObjectTypeDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv); - ObjectTypeDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped); - ObjectTypeDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped); - ObjectTypeDB::bind_method(_MD("is_cell_transposed","x","y"),&TileMap::is_cell_transposed); + ClassDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false)); + ClassDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false)); + ClassDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell); + ClassDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv); + ClassDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped); + ClassDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped); + ClassDB::bind_method(_MD("is_cell_transposed","x","y"),&TileMap::is_cell_transposed); - ObjectTypeDB::bind_method(_MD("clear"),&TileMap::clear); + ClassDB::bind_method(_MD("clear"),&TileMap::clear); - ObjectTypeDB::bind_method(_MD("get_used_cells"),&TileMap::get_used_cells); + ClassDB::bind_method(_MD("get_used_cells"),&TileMap::get_used_cells); - ObjectTypeDB::bind_method(_MD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("world_to_map","worldpos"),&TileMap::world_to_map); + ClassDB::bind_method(_MD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false)); + ClassDB::bind_method(_MD("world_to_map","worldpos"),&TileMap::world_to_map); - ObjectTypeDB::bind_method(_MD("_clear_quadrants"),&TileMap::_clear_quadrants); - ObjectTypeDB::bind_method(_MD("_recreate_quadrants"),&TileMap::_recreate_quadrants); - ObjectTypeDB::bind_method(_MD("_update_dirty_quadrants"),&TileMap::_update_dirty_quadrants); + ClassDB::bind_method(_MD("_clear_quadrants"),&TileMap::_clear_quadrants); + ClassDB::bind_method(_MD("_recreate_quadrants"),&TileMap::_recreate_quadrants); + ClassDB::bind_method(_MD("_update_dirty_quadrants"),&TileMap::_update_dirty_quadrants); - ObjectTypeDB::bind_method(_MD("_set_tile_data"),&TileMap::_set_tile_data); - ObjectTypeDB::bind_method(_MD("_get_tile_data"),&TileMap::_get_tile_data); + ClassDB::bind_method(_MD("_set_tile_data"),&TileMap::_set_tile_data); + ClassDB::bind_method(_MD("_get_tile_data"),&TileMap::_get_tile_data); ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Square,Isometric,Custom"),_SCS("set_mode"),_SCS("get_mode")); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_set",PROPERTY_HINT_RESOURCE_TYPE,"TileSet"),_SCS("set_tileset"),_SCS("get_tileset")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1",0),_SCS("_set_old_cell_size"),_SCS("_get_old_cell_size")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell/size",PROPERTY_HINT_RANGE,"1,8192,1"),_SCS("set_cell_size"),_SCS("get_cell_size")); - 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,Bottom Left"),_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")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder/light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask")); + ADD_GROUP("Cell","cell_"); + ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1"),_SCS("set_cell_size"),_SCS("get_cell_size")); + 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::TRANSFORM2D,"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,Bottom Left"),_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_GROUP("Collision","collision_"); + 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")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); + ADD_PROPERTY( PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); + + ADD_GROUP("Occluder","occluder_"); + ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder_light_mask",PROPERTY_HINT_LAYERS_2D_RENDER),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask")); + ADD_GROUP("",""); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data")); ADD_SIGNAL(MethodInfo("settings_changed")); @@ -1332,6 +1324,7 @@ TileMap::TileMap() { fp_adjust=0.00001; tile_origin=TILE_ORIGIN_TOP_LEFT; + set_notify_transform(true); } TileMap::~TileMap() { diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 7501d49aa5..ba6de62f8e 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -37,7 +37,7 @@ class TileMap : public Node2D { - OBJ_TYPE( TileMap, Node2D ); + GDCLASS( TileMap, Node2D ); public: enum Mode { @@ -66,7 +66,7 @@ private: int quadrant_size; bool center_x,center_y; Mode mode; - Matrix32 custom_transform; + Transform2D custom_transform; HalfOffset half_offset; bool use_kinematic; Navigation2D *navigation; @@ -114,12 +114,12 @@ private: struct NavPoly { int id; - Matrix32 xform; + Transform2D xform; }; struct Occluder { RID id; - Matrix32 xform; + Transform2D xform; }; @@ -153,7 +153,7 @@ private: int occluder_light_mask; - void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc); + void _fix_cell_transform(Transform2D& 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); @@ -168,8 +168,8 @@ private: _FORCE_INLINE_ int _get_quadrant_size() const; - void _set_tile_data(const DVector<int>& p_data); - DVector<int> _get_tile_data() const; + void _set_tile_data(const PoolVector<int>& p_data); + PoolVector<int> _get_tile_data() const; void _set_old_cell_size(int p_size) { set_cell_size(Size2(p_size,p_size)); } int _get_old_cell_size() const { return cell_size.x; } @@ -240,10 +240,10 @@ public: 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; + void set_custom_transform(const Transform2D& p_xform); + Transform2D get_custom_transform() const; - Matrix32 get_cell_transform() const; + Transform2D get_cell_transform() const; Vector2 get_cell_draw_offset() const; Vector2 map_to_world(const Vector2& p_pos, bool p_ignore_ofs=false) const; @@ -255,8 +255,6 @@ public: void set_occluder_light_mask(int p_mask); int get_occluder_light_mask() const; - void set_blend_mode(BlendMode p_blend_mode); - virtual void set_light_mask(int p_light_mask); void clear(); diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index 852bc187d2..f1c70a8f60 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -44,11 +44,11 @@ void VisibilityNotifier2D::_enter_viewport(Viewport* p_viewport) { return; if (viewports.size()==1) { - emit_signal(SceneStringNames::get_singleton()->enter_screen); + emit_signal(SceneStringNames::get_singleton()->screen_entered); _screen_enter(); } - emit_signal(SceneStringNames::get_singleton()->enter_viewport,p_viewport); + emit_signal(SceneStringNames::get_singleton()->viewport_entered,p_viewport); } @@ -60,9 +60,9 @@ void VisibilityNotifier2D::_exit_viewport(Viewport* p_viewport){ if (is_inside_tree() && get_tree()->is_editor_hint()) return; - emit_signal(SceneStringNames::get_singleton()->exit_viewport,p_viewport); + emit_signal(SceneStringNames::get_singleton()->viewport_exited,p_viewport); if (viewports.size()==0) { - emit_signal(SceneStringNames::get_singleton()->exit_screen); + emit_signal(SceneStringNames::get_singleton()->screen_exited); _screen_exit(); } @@ -129,22 +129,23 @@ bool VisibilityNotifier2D::is_on_screen() const { void VisibilityNotifier2D::_bind_methods(){ - ObjectTypeDB::bind_method(_MD("set_rect","rect"),&VisibilityNotifier2D::set_rect); - ObjectTypeDB::bind_method(_MD("get_rect"),&VisibilityNotifier2D::get_rect); - ObjectTypeDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier2D::is_on_screen); + ClassDB::bind_method(_MD("set_rect","rect"),&VisibilityNotifier2D::set_rect); + ClassDB::bind_method(_MD("get_rect"),&VisibilityNotifier2D::get_rect); + ClassDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier2D::is_on_screen); ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect")); - ADD_SIGNAL( MethodInfo("enter_viewport",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) ); - ADD_SIGNAL( MethodInfo("exit_viewport",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) ); - ADD_SIGNAL( MethodInfo("enter_screen")); - ADD_SIGNAL( MethodInfo("exit_screen")); + ADD_SIGNAL( MethodInfo("viewport_entered",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) ); + ADD_SIGNAL( MethodInfo("viewport_exited",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) ); + ADD_SIGNAL( MethodInfo("screen_entered")); + ADD_SIGNAL( MethodInfo("screen_exited")); } VisibilityNotifier2D::VisibilityNotifier2D() { rect=Rect2(-10,-10,20,20); + set_notify_transform(true); } @@ -232,7 +233,7 @@ void VisibilityEnabler2D::_find_nodes(Node* p_node) { if (add) { - p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT); + p_node->connect(SceneStringNames::get_singleton()->tree_exited,this,"_node_removed",varray(p_node),CONNECT_ONESHOT); nodes[p_node]=meta; _change_node_state(p_node,false); } @@ -280,7 +281,7 @@ void VisibilityEnabler2D::_notification(int p_what){ if (!visible) _change_node_state(E->key(),true); - E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed"); + E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited,this,"_node_removed"); } nodes.clear(); @@ -354,16 +355,16 @@ String VisibilityEnabler2D::get_configuration_warning() const { void VisibilityEnabler2D::_bind_methods(){ - ObjectTypeDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler2D::set_enabler); - ObjectTypeDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler2D::is_enabler_enabled); - ObjectTypeDB::bind_method(_MD("_node_removed"),&VisibilityEnabler2D::_node_removed); + ClassDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler2D::set_enabler); + ClassDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler2D::is_enabler_enabled); + ClassDB::bind_method(_MD("_node_removed"),&VisibilityEnabler2D::_node_removed); - 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); - ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animated_sprites"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATED_SPRITES); - ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_PROCESS); - ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/fixed_process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_FIXED_PROCESS); + ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS ); + ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES); + ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_particles"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES); + ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"pause_animated_sprites"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATED_SPRITES); + ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_PROCESS); + ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fixed_process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_FIXED_PROCESS); BIND_CONSTANT( ENABLER_FREEZE_BODIES ); BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS ); diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h index 354ccf4345..a896e270fe 100644 --- a/scene/2d/visibility_notifier_2d.h +++ b/scene/2d/visibility_notifier_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -34,7 +34,7 @@ class Viewport; class VisibilityNotifier2D : public Node2D { - OBJ_TYPE(VisibilityNotifier2D,Node2D); + GDCLASS(VisibilityNotifier2D,Node2D); Set<Viewport*> viewports; @@ -67,7 +67,7 @@ public: class VisibilityEnabler2D : public VisibilityNotifier2D { - OBJ_TYPE(VisibilityEnabler2D,VisibilityNotifier2D); + GDCLASS(VisibilityEnabler2D,VisibilityNotifier2D); public: enum Enabler { diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp index ed753ef745..588f343048 100644 --- a/scene/2d/y_sort.cpp +++ b/scene/2d/y_sort.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -43,10 +43,11 @@ bool YSort::is_sort_enabled() const { void YSort::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_sort_enabled","enabled"),&YSort::set_sort_enabled); - ObjectTypeDB::bind_method(_MD("is_sort_enabled"),&YSort::is_sort_enabled); + ClassDB::bind_method(_MD("set_sort_enabled","enabled"),&YSort::set_sort_enabled); + ClassDB::bind_method(_MD("is_sort_enabled"),&YSort::is_sort_enabled); - ADD_PROPERTY(PropertyInfo(Variant::BOOL,"sort/enabled"),_SCS("set_sort_enabled"),_SCS("is_sort_enabled")); + ADD_GROUP("Sort","sort_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL,"sort_enabled"),_SCS("set_sort_enabled"),_SCS("is_sort_enabled")); } diff --git a/scene/2d/y_sort.h b/scene/2d/y_sort.h index c8fa152c75..ebfe695da1 100644 --- a/scene/2d/y_sort.h +++ b/scene/2d/y_sort.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 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 */ @@ -32,7 +32,7 @@ #include "scene/2d/node_2d.h" class YSort : public Node2D { - OBJ_TYPE(YSort,Node2D); + GDCLASS(YSort,Node2D); bool sort_enabled; static void _bind_methods(); public: |