mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 12:47:12 +01:00
Ported: Disable threaded NavigationMesh bake on unsupported OS. Automatically disables threaded NavigationMesh bake when OS does not support threads. - smix8
c3b39ca1e9
This commit is contained in:
parent
4a5982b9e1
commit
ad080c7017
@ -4,7 +4,7 @@
|
||||
An instance of a [NavigationMesh].
|
||||
</brief_description>
|
||||
<description>
|
||||
An instance of a [NavigationMesh]. It tells the [Navigation] node what can be navigated and what cannot, based on the [NavigationMesh] resource. This should be a child of a [Navigation] node.
|
||||
Bakes the [NavigationMesh]. If [code]on_thread[/code] is set to [code]true[/code] (default), the baking is done on a separate thread. Baking on separate thread is useful because navigation baking is not a cheap operation. When it is completed, it automatically sets the new [NavigationMesh]. Please note that baking on separate thread may be very slow if geometry is parsed from meshes as async access to each mesh involves heavy synchronization. Also, please note that baking on a separate thread is automatically disabled on operating systems that cannot use threads (such as HTML5 with threads disabled).
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "navigation_mesh_instance.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "mesh_instance.h"
|
||||
#include "navigation.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
@ -179,7 +180,12 @@ void NavigationMeshInstance::bake_navigation_mesh(bool p_on_thread) {
|
||||
BakeThreadsArgs *args = memnew(BakeThreadsArgs);
|
||||
args->nav_region = this;
|
||||
|
||||
if (p_on_thread) {
|
||||
if (p_on_thread && !OS::get_singleton()->can_use_threads()) {
|
||||
WARN_PRINT("NavigationMesh bake 'on_thread' will be disabled as the current OS does not support multiple threads."
|
||||
"\nAs a fallback the navigation mesh will bake on the main thread which can cause framerate issues.");
|
||||
}
|
||||
|
||||
if (p_on_thread && OS::get_singleton()->can_use_threads()) {
|
||||
bake_thread.start(_bake_navigation_mesh, args);
|
||||
} else {
|
||||
_bake_navigation_mesh(args);
|
||||
|
Loading…
Reference in New Issue
Block a user