33{
34 if (*isRemeshing)
35 {
36 return;
37 }
38
39 if (appState->mode == ApplicationMode::TERRAIN)
40 {
41 appState->models.coreTerrain->UploadToGPU();
42 }
43
44 else if (appState->mode == ApplicationMode::CUSTOM_BASE)
45 {
46 appState->models.customBase->UploadToGPU();
47 }
48
49 *isRemeshing = true;
50 std::thread worker([this]
51 {
52 START_PROFILER();
53
54 if(!clearMeshGen->useGPU)
55 {
56 clearMeshGen->Generate(nullptr);
57 ExecuteCPUGenerators();
58 ExecuteKernels();
59 }
60
61 else
62 {
63 ExecuteKernels();
64 ExecuteCPUGenerators();
65 }
66
67 if(!appState->states.useGPUForNormals )
68 {
69 if (appState->mode == ApplicationMode::TERRAIN)
70 {
71 appState->models.coreTerrain->mesh->RecalculateNormals();
72 }
73
74 else if (appState->mode == ApplicationMode::CUSTOM_BASE)
75 {
76 appState->models.customBase->mesh->RecalculateNormals();
77 }
78 }
79 END_PROFILER(time);
80 *isRemeshing = false;
81 });
82 worker.detach();
83}