diff options
Diffstat (limited to 'scene/main/scene_main_loop.cpp')
-rw-r--r-- | scene/main/scene_main_loop.cpp | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index c1552a4167..cfc6753378 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -490,6 +490,8 @@ void SceneTree::input_event( const InputEvent& p_event ) { } + _call_idle_callbacks(); + } void SceneTree::init() { @@ -528,6 +530,7 @@ bool SceneTree::iteration(float p_time) { root_lock--; _flush_delete_queue(); + _call_idle_callbacks(); return _quit; } @@ -590,6 +593,8 @@ bool SceneTree::idle(float p_time){ E=N; } + _call_idle_callbacks(); + return _quit; } @@ -745,12 +750,12 @@ Ref<Material> SceneTree::get_debug_navigation_material() { if (navigation_material.is_valid()) return navigation_material; - Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial )); + Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); /* line_material->set_flag(Material::FLAG_UNSHADED, true); line_material->set_line_width(3.0); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); - line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_color());*/ + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true); + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true); + line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_navigation_color());*/ navigation_material=line_material; @@ -763,12 +768,12 @@ Ref<Material> SceneTree::get_debug_navigation_disabled_material(){ if (navigation_disabled_material.is_valid()) return navigation_disabled_material; - Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial )); + Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); /* line_material->set_flag(Material::FLAG_UNSHADED, true); line_material->set_line_width(3.0); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); - line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());*/ + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true); + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true); + line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());*/ navigation_disabled_material=line_material; @@ -781,12 +786,12 @@ Ref<Material> SceneTree::get_debug_collision_material() { return collision_material; - Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial )); + Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial )); /*line_material->set_flag(Material::FLAG_UNSHADED, true); line_material->set_line_width(3.0); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); - line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true); - line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collisions_color());*/ + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true); + line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true); + line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_collisions_color());*/ collision_material=line_material; @@ -800,11 +805,11 @@ Ref<Mesh> SceneTree::get_debug_contact_mesh() { debug_contact_mesh = Ref<Mesh>( memnew( Mesh ) ); - Ref<FixedMaterial> mat = memnew( FixedMaterial ); + Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial ); /*mat->set_flag(Material::FLAG_UNSHADED,true); mat->set_flag(Material::FLAG_DOUBLE_SIDED,true); - mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true); - mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());*/ + mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true); + mat->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());*/ Vector3 diamond[6]={ Vector3(-1, 0, 0), @@ -2259,6 +2264,23 @@ void SceneTree::_bind_methods() { SceneTree *SceneTree::singleton=NULL; + +SceneTree::IdleCallback SceneTree::idle_callbacks[SceneTree::MAX_IDLE_CALLBACKS]; +int SceneTree::idle_callback_count=0; + +void SceneTree::_call_idle_callbacks() { + + for(int i=0;i<idle_callback_count;i++) { + idle_callbacks[i](); + } +} + +void SceneTree::add_idle_callback(IdleCallback p_callback) { + ERR_FAIL_COND(idle_callback_count>=MAX_IDLE_CALLBACKS); + idle_callbacks[idle_callback_count++]=p_callback; +} + + SceneTree::SceneTree() { singleton=this; |