Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kade-github committed Apr 26, 2024
1 parent 2ff09b9 commit 99b9be7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
25 changes: 18 additions & 7 deletions src/Game/Scenes/Gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ void Gameplay::UpdateChunks()
{
Game::instance->log->Write("Loading region: " + std::to_string(pos.x * regionSize) + ", " + std::to_string(pos.y * regionSize));
toLoadedRegion.push_back(pos);
wm->LoadRegion(pos.x, pos.y);
loadPool.detach_task([this, pos]()
{
wm->LoadRegion(pos.x, pos.y);
});

// Queue load for edge chunks

Expand All @@ -403,7 +406,11 @@ void Gameplay::UpdateChunks()
{
Game::instance->log->Write("Loading region: " + std::to_string(pos.x * regionSize) + ", " + std::to_string(pos.y * regionSize));
toLoadedRegion.push_back(pos);
wm->LoadRegion(pos.x, pos.y);
loadPool.detach_task([this, pos]()
{
wm->LoadRegion(pos.x, pos.y);
});


// Queue load for edge chunks

Expand All @@ -424,7 +431,10 @@ void Gameplay::UpdateChunks()
{
Game::instance->log->Write("Loading region: " + std::to_string(pos.x * regionSize) + ", " + std::to_string(pos.y * regionSize));
toLoadedRegion.push_back(pos);
wm->LoadRegion(pos.x, pos.y);
loadPool.detach_task([this, pos]()
{
wm->LoadRegion(pos.x, pos.y);
});

// Queue load for edge chunks

Expand All @@ -445,7 +455,10 @@ void Gameplay::UpdateChunks()
{
Game::instance->log->Write("Loading region: " + std::to_string(pos.x * regionSize) + ", " + std::to_string(pos.y * regionSize));
toLoadedRegion.push_back(pos);
wm->LoadRegion(pos.x, pos.y);
loadPool.detach_task([this, pos]()
{
wm->LoadRegion(pos.x, pos.y);
});

// Queue load for edge chunks

Expand Down Expand Up @@ -479,8 +492,6 @@ void Gameplay::UpdateChunks()
if (Settings::instance->fogDistance >= 2.0)
fog = 10000;

float fovModifier = Settings::instance->fov / 75.0f;

for (Chunk* c : allChunks)
{
glm::vec3 fakePosC = glm::vec3(c->position.x, 0, c->position.z);
Expand All @@ -503,7 +514,7 @@ void Gameplay::UpdateChunks()

float angle = camera->YawAngleTo(fakePosC);

if ((angle <= (180 * fovModifier) || distance <= 32) && distance <= fog + 32)
if ((angle <= 260 || distance <= 32) && distance <= fog + 32)
{
if (!c->isRendered || c->pleaseRender)
{
Expand Down
27 changes: 17 additions & 10 deletions src/Game/Scenes/SettingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ void SettingsMenu::Create()

c2d->AddObject(fov);

float renderDistancePerc = Settings::instance->renderDistance / 1.0f;
float renderDistancePerc = Settings::instance->renderDistance / 2.0f;

if (renderDistancePerc < 0.1f)
renderDistancePerc = 0.1f;

if (renderDistancePerc > 2.0f)
renderDistancePerc = 2.0f;
if (renderDistancePerc > 1.0f)
renderDistancePerc = 1.0f;

renderDistance = new DragBar(glm::vec3(0, 0, 0), "Render Distance", renderDistancePerc);

Expand All @@ -79,8 +79,8 @@ void SettingsMenu::Create()
if (fogDistancePerc < 0.1f)
fogDistancePerc = 0.1f;

if (fogDistancePerc > 2.0f)
fogDistancePerc = 2.0f;
if (fogDistancePerc > 1.0f)
fogDistancePerc = 1.0f;

fogDistance = new DragBar(glm::vec3(0, 0, 0), "Fog Distance", fogDistancePerc);

Expand Down Expand Up @@ -122,10 +122,6 @@ void SettingsMenu::Draw()
else
back->selected = false;

Settings::instance->fov = fov->value * 140;
Settings::instance->renderDistance = renderDistance->value * 2.0f;
Settings::instance->fogDistance = fogDistance->value * 1.2f;

Scene::Draw();
}

Expand Down Expand Up @@ -161,4 +157,15 @@ void SettingsMenu::Resize(float _w, float _h)
{
if (c2d != nullptr)
c2d->Resize();
}
}

void SettingsMenu::Destroy()
{
Settings::instance->fov = fov->value * 140;
Settings::instance->renderDistance = renderDistance->value * 2.0f;
Settings::instance->fogDistance = fogDistance->value * 2.0f;


Settings::instance->Save();
Scene::Destroy();
}
2 changes: 2 additions & 0 deletions src/Game/Scenes/SettingsMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class SettingsMenu : public Scene
void MouseClick(int button, glm::vec2 mPos) override;
void MouseRelease(int button, glm::vec2 mPos) override;
void Resize(float _w, float _h) override;

void Destroy() override;
};

#endif
1 change: 0 additions & 1 deletion src/Game/WorldManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ void WorldManager::CheckGeneratedRegions()
{
if (_generatedRegions.size() != 0)
{
std::lock_guard<std::mutex> lock(generateMutex);
for (Region r : _generatedRegions)
regions.push_back(r);

Expand Down

0 comments on commit 99b9be7

Please sign in to comment.