smirnov.oleg Posted March 15, 2019 Share Posted March 15, 2019 (edited) Hi. I'm working with ObjectTerrainGlobal. Modifying height maps, normal maps and detail masks at runtime. My problem is that saveAll() function of TileSet class is running slow thus it freezes main thread no letting any gui updates. What i want to do is to add some progress bar to let user know that this operation takes long time to complete, just simple hanging is not acceptable. In general it would be very useful to have some sort of function to force engine to render gui from child thread (or atleast from main thread) to display the progress of any operations that take a long time. Any advices? Edited March 15, 2019 by smirnov.oleg Link to comment
andrey-kozlov Posted March 15, 2019 Share Posted March 15, 2019 Hello Oleg, The main pattern for such a task is to move long work to other thread to keep main-loop free for the status reporting. If it doesn't suit for the case for some reasons you have control over the main-loop and could call its methods manually (https://developer.unigine.com/en/docs/2.7.3/api/library/engine/class.engine#main_SystemLogic_ptr_WorldLogic_ptr_EditorLogic_ptr_void ). Link to comment
smirnov.oleg Posted March 15, 2019 Author Share Posted March 15, 2019 So is that ok to call saveAll() function of TileSet class from another thread? Or can i do world intersections from another thread? Link to comment
andrey-kozlov Posted March 18, 2019 Share Posted March 18, 2019 Hello Oleg, Internal structures of tileset are protected by mutex so calling saveAll from a worker thread should be ok. Synchronization may lead to performance overhead though. It's not so easy with world intersections since objects can be deleted from the main thread or objects movement can lead to the spatial structures update. May be fine if nothing changes in the world. Link to comment
smirnov.oleg Posted March 18, 2019 Author Share Posted March 18, 2019 Alright thanks for info Andrey.I was trying to make tile saving in separate thread and had some weird problems with it. It turned out that the problem was different. Link to comment
Recommended Posts