partial fix

main
Brett 2023-03-09 00:50:23 -05:00
parent c6b65951b7
commit a375f4289b
3 changed files with 13 additions and 7 deletions

View File

@ -34,7 +34,8 @@ class frustum {
}
[[nodiscard]] inline float distance(const blt::vec3& point) const {
return m_A * point.x() + m_B * point.y() + m_C * point.z() + m_D;
auto dist = m_A * point.x() + m_B * point.y() + m_C * point.z() + m_D;
return dist;
}
[[nodiscard]] inline float A() const { return m_A; }
@ -111,8 +112,9 @@ class frustum {
// std::all_of ??
for (auto plane : planes){
// point is outside plane
if (plane.distance(point) < 0)
if (plane.distance(point) < 0) {
return false;
}
}
return true;
}

View File

@ -62,15 +62,15 @@ namespace fp::_static {
}
const blt::mat4x4& fp::getViewMatrix() {
return _static::projectionMatrix;
return _static::viewMatrix;
}
const blt::mat4x4& fp::getProjectionMatrix() {
return _static::orthographicMatrix;
return _static::projectionMatrix;
}
const blt::mat4x4& fp::getOrthographicMatrix() {
return _static::viewMatrix;
return _static::orthographicMatrix;
}
namespace fp {

View File

@ -174,12 +174,16 @@ void fp::world::render(fp::shader& shader) {
}
auto cp = blt::vec3{(float)adjusted_chunk_pos.x, (float)adjusted_chunk_pos.y, (float)adjusted_chunk_pos.z};
auto cp2 = cp + blt::vec3{CHUNK_SIZE, CHUNK_SIZE, CHUNK_SIZE};
if (view_frustum.cubeInside(cp, cp2))
auto cp2 = cp + blt::vec3{CHUNK_SIZE, 0, 0};
auto cp3 = cp + blt::vec3{0, CHUNK_SIZE, 0};
auto cp4 = cp + blt::vec3{0, 0, CHUNK_SIZE};
auto cp5 = cp + blt::vec3{CHUNK_SIZE, CHUNK_SIZE, CHUNK_SIZE};
if (view_frustum.pointInside(cp) || view_frustum.pointInside(cp2) || view_frustum.pointInside(cp3) || view_frustum.pointInside(cp4) || view_frustum.pointInside(cp5))
chunk->render(shader);
}
}
}
//std::cout << "0,0,0 in frustum? " << view_frustum.pointInside(blt::vec3{0,0,0}) << "\n";
}
fp::chunk* fp::world::generateChunk(const fp::chunk_pos& pos) {