Disable threaded NavigationMesh bake on unsupported OS
Automatically disables threaded NavigationMesh bake when OS does not support threads.
(cherry picked from commit 49c603e127
)
This commit is contained in:
parent
b11708c50d
commit
c3b39ca1e9
|
@ -13,7 +13,7 @@
|
|||
<return type="void" />
|
||||
<argument index="0" name="on_thread" type="bool" default="true" />
|
||||
<description>
|
||||
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.
|
||||
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>
|
||||
</method>
|
||||
<method name="get_region_rid" qualifiers="const">
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "navigation_mesh_instance.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "core/os/thread.h"
|
||||
#include "mesh_instance.h"
|
||||
#include "navigation.h"
|
||||
|
@ -178,7 +179,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