From 4b58d453d49c2ac8aa30b3e132b8a3eae316e4fe Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Tue, 28 Apr 2020 10:25:07 +0300 Subject: [PATCH] Expose the cell_size affecting VisibilityNotifier2D precision Refs: #4803 (cherry picked from commit d49ff7aff7783a6334de48f7086752a713590e5c) --- doc/classes/ProjectSettings.xml | 3 +++ doc/classes/VisibilityEnabler2D.xml | 2 +- doc/classes/VisibilityNotifier2D.xml | 2 +- scene/resources/world_2d.cpp | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 248975adf58..d049eaec324 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1164,6 +1164,9 @@ If [code]true[/code], the texture importer will import VRAM-compressed textures using the S3 Texture Compression algorithm. This algorithm is only supported on desktop platforms and consoles. + + Cell size used for the 2D hash grid that [VisibilityNotifier2D] uses. + diff --git a/doc/classes/VisibilityEnabler2D.xml b/doc/classes/VisibilityEnabler2D.xml index ca342300e05..1cb0c3fc5ab 100644 --- a/doc/classes/VisibilityEnabler2D.xml +++ b/doc/classes/VisibilityEnabler2D.xml @@ -5,7 +5,7 @@ The VisibilityEnabler2D will disable [RigidBody2D], [AnimationPlayer], and other nodes when they are not visible. It will only affect nodes with the same root node as the VisibilityEnabler2D, and the root node itself. - [b]Note:[/b] VisibilityEnabler2D uses an approximate heuristic for performance reasons. If you need exact visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. + [b]Note:[/b] For performance reasons, VisibilityEnabler2D uses an approximate heuristic with precision determined by [member ProjectSettings.world/2d/cell_size]. If you need exact visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. [b]Note:[/b] VisibilityEnabler2D will not affect nodes added after scene initialization. diff --git a/doc/classes/VisibilityNotifier2D.xml b/doc/classes/VisibilityNotifier2D.xml index 09d3e62acf6..a86ba38126c 100644 --- a/doc/classes/VisibilityNotifier2D.xml +++ b/doc/classes/VisibilityNotifier2D.xml @@ -5,7 +5,7 @@ The VisibilityNotifier2D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a viewport. - [b]Note:[/b] VisibilityNotifier2D uses an approximate heuristic for performance reasons. If you need exact visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. + [b]Note:[/b] For performance reasons, VisibilityNotifier2D uses an approximate heuristic with precision determined by [member ProjectSettings.world/2d/cell_size]. If you need exact visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 5cc809d8e3f..13d5c9699f3 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -314,7 +314,7 @@ struct SpatialIndexer2D { pass = 0; changed = false; - cell_size = 100; //should be configurable with GLOBAL_DEF("") i guess + cell_size = GLOBAL_DEF("world/2d/cell_size", 100); } };