Merge pull request #39644 from Ev1lbl0w/feature/disable-rendering

Expose disable_render_loop property to GDScript
This commit is contained in:
Rémi Verschelde 2020-06-19 12:54:04 +02:00 committed by GitHub
commit 6c6a203e26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View File

@ -4231,6 +4231,11 @@
</description> </description>
</method> </method>
</methods> </methods>
<members>
<member name="render_loop_enabled" type="bool" setter="set_render_loop_enabled" getter="is_render_loop_enabled">
If [code]false[/code], disables rendering completely, but the engine logic is still being processed. You can call [method force_draw] to draw a frame even with rendering disabled.
</member>
</members>
<signals> <signals>
<signal name="frame_post_draw"> <signal name="frame_post_draw">
<description> <description>

View File

@ -1271,6 +1271,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
// also init our arvr_server from here // also init our arvr_server from here
arvr_server = memnew(ARVRServer); arvr_server = memnew(ARVRServer);
// and finally setup this property under visual_server
VisualServer::get_singleton()->set_render_loop_enabled(!disable_render_loop);
register_core_singletons(); register_core_singletons();
MAIN_PRINT("Main: Setup Logo"); MAIN_PRINT("Main: Setup Logo");
@ -2101,7 +2104,7 @@ bool Main::iteration() {
VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames. VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames.
if (OS::get_singleton()->can_draw() && !disable_render_loop) { if (OS::get_singleton()->can_draw() && VisualServer::get_singleton()->is_render_loop_enabled()) {
if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) { if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) {
if (VisualServer::get_singleton()->has_changed()) { if (VisualServer::get_singleton()->has_changed()) {

View File

@ -2050,6 +2050,10 @@ void VisualServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &VisualServer::has_os_feature); ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &VisualServer::has_os_feature);
ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &VisualServer::set_debug_generate_wireframes); ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &VisualServer::set_debug_generate_wireframes);
ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &VisualServer::is_render_loop_enabled);
ClassDB::bind_method(D_METHOD("set_render_loop_enabled", "enabled"), &VisualServer::set_render_loop_enabled);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_loop_enabled"), "set_render_loop_enabled", "is_render_loop_enabled");
BIND_CONSTANT(NO_INDEX_ARRAY); BIND_CONSTANT(NO_INDEX_ARRAY);
BIND_CONSTANT(ARRAY_WEIGHTS_SIZE); BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
BIND_CONSTANT(CANVAS_ITEM_Z_MIN); BIND_CONSTANT(CANVAS_ITEM_Z_MIN);
@ -2368,6 +2372,14 @@ RID VisualServer::instance_create2(RID p_base, RID p_scenario) {
return instance; return instance;
} }
bool VisualServer::is_render_loop_enabled() const {
return render_loop_enabled;
}
void VisualServer::set_render_loop_enabled(bool p_enabled) {
render_loop_enabled = p_enabled;
}
VisualServer::VisualServer() { VisualServer::VisualServer() {
//ERR_FAIL_COND(singleton); //ERR_FAIL_COND(singleton);

View File

@ -46,6 +46,7 @@ class VisualServer : public Object {
static VisualServer *singleton; static VisualServer *singleton;
int mm_policy; int mm_policy;
bool render_loop_enabled = true;
void _camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far); void _camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far);
void _canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate = Color(1, 1, 1)); void _canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate = Color(1, 1, 1));
@ -1063,6 +1064,9 @@ public:
virtual bool is_low_end() const = 0; virtual bool is_low_end() const = 0;
bool is_render_loop_enabled() const;
void set_render_loop_enabled(bool p_enabled);
VisualServer(); VisualServer();
virtual ~VisualServer(); virtual ~VisualServer();
}; };