diff options
Diffstat (limited to 'scene/main/scene_main_loop.cpp')
| -rw-r--r-- | scene/main/scene_main_loop.cpp | 117 |
1 files changed, 85 insertions, 32 deletions
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index d233bf1a7..147409a86 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -141,7 +141,7 @@ void SceneTree::_flush_ugc() { for(int i=0;i<E->get().size();i++) v[i]=E->get()[i]; - call_group(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]); + call_group_flags(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]); unique_group_calls.erase(E); } @@ -166,7 +166,7 @@ void SceneTree::_update_group_order(Group& g) { } -void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) { +void SceneTree::call_group_flags(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) { Map<StringName,Group>::Element *E=group_map.find(p_group); if (!E) @@ -216,7 +216,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const continue; if (p_call_flags&GROUP_CALL_REALTIME) { - if (p_call_flags&GROUP_CALL_MULIILEVEL) + if (p_call_flags&GROUP_CALL_MULTILEVEL) nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS); else nodes[i]->call(p_function,VARIANT_ARG_PASS); @@ -233,7 +233,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const continue; if (p_call_flags&GROUP_CALL_REALTIME) { - if (p_call_flags&GROUP_CALL_MULIILEVEL) + if (p_call_flags&GROUP_CALL_MULTILEVEL) nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS); else nodes[i]->call(p_function,VARIANT_ARG_PASS); @@ -248,7 +248,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const call_skip.clear(); } -void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification) { +void SceneTree::notify_group_flags(uint32_t p_call_flags,const StringName& p_group,int p_notification) { Map<StringName,Group>::Element *E=group_map.find(p_group); if (!E) @@ -298,7 +298,7 @@ void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int call_skip.clear(); } -void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) { +void SceneTree::set_group_flags(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) { Map<StringName,Group>::Element *E=group_map.find(p_group); if (!E) @@ -348,6 +348,23 @@ void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const call_skip.clear(); } + +void SceneTree::call_group(const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) { + + call_group_flags(0,p_group,VARIANT_ARG_PASS); +} + +void SceneTree::notify_group(const StringName& p_group,int p_notification) { + + notify_group_flags(0,p_group,p_notification); +} + +void SceneTree::set_group(const StringName& p_group,const String& p_name,const Variant& p_value) { + + set_group_flags(0,p_group,p_name,p_value); +} + + void SceneTree::set_input_as_handled() { input_handled=true; @@ -357,7 +374,7 @@ void SceneTree::input_text( const String& p_text ) { root_lock++; - call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check + call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check root_lock--; @@ -438,21 +455,22 @@ void SceneTree::input_event( const InputEvent& p_event ) { //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input","_input",ev); - /*if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F12) { + /* + if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F12) { print_line("RAM: "+itos(Memory::get_static_mem_usage())); print_line("DRAM: "+itos(Memory::get_dynamic_mem_usage())); } -*/ - //if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F11) { + if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F11) { - // Memory::dump_static_mem_to_file("memdump.txt"); - //} + Memory::dump_static_mem_to_file("memdump.txt"); + } + */ //transform for the rest #else - call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check + call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check #endif if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote() && ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F8) { @@ -477,7 +495,7 @@ void SceneTree::input_event( const InputEvent& p_event ) { } #else - call_group(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check + call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check #endif input_handled=true; @@ -528,7 +546,7 @@ bool SceneTree::iteration(float p_time) { _notify_group_pause("fixed_process",Node::NOTIFICATION_FIXED_PROCESS); _flush_ugc(); _flush_transform_notifications(); - call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds"); + call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds"); root_lock--; _flush_delete_queue(); @@ -540,9 +558,9 @@ bool SceneTree::iteration(float p_time) { bool SceneTree::idle(float p_time){ -// print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage())); -// print_line("node count: "+itos(get_node_count())); -// print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED))); + //print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage())); + //print_line("node count: "+itos(get_node_count())); + //print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED))); root_lock++; @@ -573,7 +591,7 @@ bool SceneTree::idle(float p_time){ _flush_ugc(); _flush_transform_notifications(); //transforms after world update, to avoid unnecesary enter/exit notifications - call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds"); + call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds"); root_lock--; @@ -667,7 +685,7 @@ void SceneTree::_notification(int p_notification) { } break; case NOTIFICATION_WM_UNFOCUS_REQUEST: { - notify_group(GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST); + notify_group_flags(GROUP_CALL_REALTIME|GROUP_CALL_MULTILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST); } break; @@ -991,7 +1009,7 @@ uint32_t SceneTree::get_last_event_id() const { } -Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { +Variant SceneTree::_call_group_flags(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { r_error.error=Variant::CallError::CALL_OK; @@ -1011,11 +1029,33 @@ Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant:: v[i]=*p_args[i+3]; } - call_group(flags,group,method,v[0],v[1],v[2],v[3],v[4]); + call_group_flags(flags,group,method,v[0],v[1],v[2],v[3],v[4]); return Variant(); } +Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { + + + r_error.error=Variant::CallError::CALL_OK; + + ERR_FAIL_COND_V(p_argcount<2,Variant()); + ERR_FAIL_COND_V(p_args[0]->get_type()!=Variant::STRING,Variant()); + ERR_FAIL_COND_V(p_args[1]->get_type()!=Variant::STRING,Variant()); + + StringName group = *p_args[0]; + StringName method = *p_args[1]; + Variant v[VARIANT_ARG_MAX]; + + for(int i=0;i<MIN(p_argcount-2,5);i++) { + + v[i]=*p_args[i+2]; + } + + call_group_flags(0,group,method,v[0],v[1],v[2],v[3],v[4]); + return Variant(); +} + int64_t SceneTree::get_frame() const { return current_frame; @@ -1138,8 +1178,8 @@ void SceneTree::_update_root_rect() { Size2 viewport_size; Size2 screen_size; - float viewport_aspect = desired_res.get_aspect(); - float video_mode_aspect = video_mode.get_aspect(); + float viewport_aspect = desired_res.aspect(); + float video_mode_aspect = video_mode.aspect(); if (stretch_aspect==STRETCH_ASPECT_IGNORE || ABS(viewport_aspect - video_mode_aspect)<CMP_EPSILON) { //same aspect or ignore aspect @@ -1198,8 +1238,8 @@ void SceneTree::_update_root_rect() { VisualServer::get_singleton()->black_bars_set_margins(0,0,0,0); } -// print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size)); -// print_line("SS: "+video_mode); + //print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size)); + //print_line("SS: "+video_mode); switch (stretch_mode) { case STRETCH_MODE_2D: { @@ -2181,10 +2221,6 @@ void SceneTree::_bind_methods() { //ClassDB::bind_method(_MD("call_group","call_flags","group","method","arg1","arg2"),&SceneMainLoop::_call_group,DEFVAL(Variant()),DEFVAL(Variant())); - ClassDB::bind_method(_MD("notify_group","call_flags","group","notification"),&SceneTree::notify_group); - ClassDB::bind_method(_MD("set_group","call_flags","group","property","value"),&SceneTree::set_group); - - ClassDB::bind_method(_MD("get_nodes_in_group","group"),&SceneTree::_get_nodes_in_group); ClassDB::bind_method(_MD("get_root:Viewport"),&SceneTree::get_root); ClassDB::bind_method(_MD("has_group","name"),&SceneTree::has_group); @@ -2222,13 +2258,30 @@ void SceneTree::_bind_methods() { MethodInfo mi; - mi.name="call_group"; + mi.name="call_group_flags"; mi.arguments.push_back( PropertyInfo( Variant::INT, "flags")); mi.arguments.push_back( PropertyInfo( Variant::STRING, "group")); mi.arguments.push_back( PropertyInfo( Variant::STRING, "method")); - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi); + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group_flags",&SceneTree::_call_group_flags,mi); + + ClassDB::bind_method(_MD("notify_group_flags","call_flags","group","notification"),&SceneTree::notify_group_flags); + ClassDB::bind_method(_MD("set_group_flags","call_flags","group","property","value"),&SceneTree::set_group_flags); + + MethodInfo mi2; + mi2.name="call_group"; + mi2.arguments.push_back( PropertyInfo( Variant::STRING, "group")); + mi2.arguments.push_back( PropertyInfo( Variant::STRING, "method")); + + + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi2); + + ClassDB::bind_method(_MD("notify_group","call_flags","group","notification"),&SceneTree::notify_group); + ClassDB::bind_method(_MD("set_group","call_flags","group","property","value"),&SceneTree::set_group); + + ClassDB::bind_method(_MD("get_nodes_in_group","group"),&SceneTree::_get_nodes_in_group); + ClassDB::bind_method(_MD("set_current_scene","child_node:Node"),&SceneTree::set_current_scene); ClassDB::bind_method(_MD("get_current_scene:Node"),&SceneTree::get_current_scene); |
