summaryrefslogtreecommitdiffstats
path: root/src/RendererWorld.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-03-29 12:03:58 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-03-30 01:01:51 +0200
commitbf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06 (patch)
treeff2dc007c07960afa3e121cfd97c82a0de67e795 /src/RendererWorld.cpp
parentNum of parsing threads now depends from num of CPU cores (diff)
downloadAltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar
AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.gz
AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.bz2
AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.lz
AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.xz
AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.zst
AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.zip
Diffstat (limited to 'src/RendererWorld.cpp')
-rw-r--r--src/RendererWorld.cpp40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index aa64dc0..5d0d6a8 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -148,7 +148,6 @@ void RendererWorld::UpdateAllSections(VectorF playerPos) {
RendererWorld::RendererWorld(GameState* ptr) {
gs = ptr;
- frustum = std::make_unique<Frustum>();
MaxRenderingDistance = 2;
numOfWorkers = _max(1, (signed int) std::thread::hardware_concurrency() - 2);
@@ -396,38 +395,19 @@ void RendererWorld::Render(RenderState & renderState) {
glUniform2f(windowSizeLoc, renderState.WindowWidth, renderState.WindowHeight);
glCheckError();
- frustum->UpdateFrustum(projView);
+ Frustum frustum(projView);
size_t culledSections = sections.size();
- for (auto& section : sections) {
- const static Vector sectionCorners[] = {
- Vector(0, 0, 0),
- Vector(0, 0, 16),
- Vector(0, 16, 0),
- Vector(0, 16, 16),
- Vector(16, 0, 0),
- Vector(16, 0, 16),
- Vector(16, 16, 0),
- Vector(16, 16, 16),
- };
- bool isVisible = false;
- for (const auto &it : sectionCorners) {
- VectorF point(section.second.GetPosition().x * 16 + it.x,
- section.second.GetPosition().y * 16 + it.y,
- section.second.GetPosition().z * 16 + it.z);
- if (frustum->TestPoint(point)) {
- isVisible = true;
- break;
- }
- }
-
- double lengthToSection = (gs->player->pos -
- VectorF(section.first.x*16,
- section.first.y*16,
- section.first.z*16)
- ).GetLength();
+ for (auto& section : sections) {
+ glm::vec3 point{
+ section.second.GetPosition().x * 16 + 8,
+ section.second.GetPosition().y * 16 + 8,
+ section.second.GetPosition().z * 16 + 8
+ };
+
+ bool isVisible = frustum.TestSphere(point, 16.0f);
- if (!isVisible && lengthToSection > 30.0f) {
+ if (!isVisible) {
culledSections--;
continue;
}