Hi again.
Maybe you want to help me if I add a little more details.
I stole whole code from this perfect example of this awesome guy
.
His example works brilliant, but while I fly for long time in one direction terrain generation and release start to be late. I start to fly over the abyss and square of generated terrain crawling from behind.
I try to add little multithreading but I ruined everything. In different variations. Try to use mutex, try to call Thread.new() in different places etc. Maximum I reach is blinking separate terrain chunks before everything crush with 200 thread errors in debugger.
So I restore awesome man with nick "codat"'s code.
And little copypaste in places where was word "thread"
to
this
var thread1
var thread2
var thread3
var thread4
this
thread1 = Thread.new()
thread2 = Thread.new()
thread3 = Thread.new()
thread4 = Thread.new()
and this
# see if thread is not active at the moment (working on another chunk)
if not thread1.is_active():
thread1.start(self, "load_chunk", [thread1, x, z])
unready_chunks[key] = 1
elif not thread2.is_active():
thread2.start(self, "load_chunk", [thread2, x, z])
unready_chunks[key] = 1
elif not thread3.is_active():
thread3.start(self, "load_chunk", [thread3, x, z])
unready_chunks[key] = 1
elif not thread4.is_active():
thread4.start(self, "load_chunk", [thread4, x, z])
unready_chunks[key] = 1
Game start to generate terrain faster (terrain generates faster than I fly) but I have cath freeze and framerate fall from 60(I set ProjectSettings-Debug-Settings-Force Fps=60 idk did it matter) to 19. But my GPU-Z shows GPU loading 3%. My SysinternalsProcessExplorer (PE) shows Godot eat 25% CPU. To be honest Godot eats 25% of CPU even if nothing happens while project running (doesnt matter which project).

Then I try to switch bios setting "hypertreading", set it "on", Godot starts to eat 12,5 instead of 25%%.
My CPU has 4 cores, "hyperthreading" make windows task manager shows 8 cores to me, so I turn off heperthreading back.
Then I stole from stackoverflow little piece of c++
#include <windows.h>
#include <process.h>
#include <time.h>
#include <stdio.h>
void task1(void *){
while(1) {
clock_t wakeup = clock() + 50;
while(clock() < wakeup) {}
Sleep(50);
}
}
int main(int, char**){
int ThreadNr;
for(int i=0; i < 8; i++) _beginthread( task1, 0, &ThreadNr );
(void) getchar();
return 0;
}
and it shows me 88% .

So can I get some answer (code example to load CPU high)? At least "you idiot (sandwich) do everything wrong and look wrong way" idk.