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))); root_lock++; MainLoop::idle(p_time); idle_process_time=p_time; emit_signal("idle_frame"); _flush_transform_notifications(); _notify_group_pause("idle_process",Node::NOTIFICATION_PROCESS); Size2 win_size=Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height ); if(win_size!=last_screen_size) { last_screen_size=win_size; _update_root_rect(); emit_signal("screen_resized"); } _flush_ugc(); _flush_transform_notifications(); //transforms after world update, to avoid unnecesary enter/exit notifications call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds"); root_lock--; _flush_delete_queue(); return _quit; }
bool SceneMainLoop::iteration(float p_time) { root_lock++; current_frame++; _flush_transform_notifications(); MainLoop::iteration(p_time); fixed_process_time=p_time; _notify_group_pause("fixed_process",Node::NOTIFICATION_FIXED_PROCESS); _flush_ugc(); _flush_transform_notifications(); call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds"); root_lock--; _flush_delete_queue(); return _quit; }
void SceneMainLoop::finish() { _flush_delete_queue(); _flush_ugc(); initialized=false; MainLoop::finish(); if (root) { root->_set_scene(NULL); memdelete(root); //delete root } }
void SceneMainLoop::input_event( const InputEvent& p_event ) { root_lock++; last_id=p_event.ID; input_handled=false; InputEvent ev = p_event; #if 0 switch(ev.type) { case InputEvent::MOUSE_BUTTON: { Matrix32 ai = root->get_final_transform().affine_inverse(); Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y)); Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y)); ev.mouse_button.x=l.x; ev.mouse_button.y=l.y; ev.mouse_button.global_x=g.x; ev.mouse_button.global_y=g.y; } break; case InputEvent::MOUSE_MOTION: { Matrix32 ai = root->get_final_transform().affine_inverse(); Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y)); Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y)); Vector2 r = ai.xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y)); ev.mouse_motion.x=l.x; ev.mouse_motion.y=l.y; ev.mouse_motion.global_x=g.x; ev.mouse_motion.global_y=g.y; ev.mouse_motion.relative_x=r.x; ev.mouse_motion.relative_y=r.y; } break; case InputEvent::SCREEN_TOUCH: { Matrix32 ai = root->get_final_transform().affine_inverse(); Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y)); ev.screen_touch.x=t.x; ev.screen_touch.y=t.y; } break; case InputEvent::SCREEN_DRAG: { Matrix32 ai = root->get_final_transform().affine_inverse(); Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y)); Vector2 r = ai.xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y)); Vector2 s = ai.xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y)); ev.screen_drag.x=t.x; ev.screen_drag.y=t.y; ev.screen_drag.relative_x=r.x; ev.screen_drag.relative_y=r.y; ev.screen_drag.speed_x=s.x; ev.screen_drag.speed_y=s.y; } break; } #endif MainLoop::input_event(p_event); #if 0 _call_input_pause("input","_input",ev); call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"_gui_input","_gui_input",p_event); //special one for GUI, as controls use their own process check //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) { 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) { // Memory::dump_static_mem_to_file("memdump.txt"); //} //transform for the rest #else call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input",p_event); //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) { ScriptDebugger::get_singleton()->request_quit(); } _flush_ugc(); root_lock--; MessageQueue::get_singleton()->flush(); //small little hack root_lock++; if (!input_handled) { #if 0 _call_input_pause("unhandled_input","_unhandled_input",ev); //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev); if (!input_handled && ev.type==InputEvent::KEY) { _call_input_pause("unhandled_key_input","_unhandled_key_input",ev); //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev); } #else call_group(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",p_event); //special one for GUI, as controls use their own process check #endif input_handled=true; _flush_ugc(); root_lock--; MessageQueue::get_singleton()->flush(); //small little hack } else { input_handled=true; root_lock--; } }