, slabShape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.0f, 0.5f }})
, blockNoise(0)
, colorNoise(1)
, slabShape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.0f, 0.5f }})
, blockNoise(0)
, colorNoise(1)
, loaded()
, to_generate() {
blockType.Add(BlockType{ true, { 1.0f, 1.0f, 1.0f }, &blockShape }); // white block
, loaded()
, to_generate() {
blockType.Add(BlockType{ true, { 1.0f, 1.0f, 1.0f }, &blockShape }); // white block
- if (cur_chunk.Intersection(ray, M * cur_chunk.Transform(), &cur_blkid, &cur_dist, &cur_normal)) {
+ if (cur_chunk.Intersection(ray, M * cur_chunk.Transform(player.ChunkCoords()), &cur_blkid, &cur_dist, &cur_normal)) {
if (cur_dist < closest_dist) {
closest_chunk = &cur_chunk;
closest_blkid = cur_blkid;
if (cur_dist < closest_dist) {
closest_chunk = &cur_chunk;
closest_blkid = cur_blkid;
void World::Render(DirectionalLighting &program) {
program.SetLightDirection({ -1.0f, -3.0f, -2.0f });
void World::Render(DirectionalLighting &program) {
program.SetLightDirection({ -1.0f, -3.0f, -2.0f });
- program.SetM(chunk.Transform());
- chunk.Draw();
+ glm::mat4 m(chunk.Transform(player.ChunkCoords()));
+ program.SetM(m);
+ glm::mat4 mvp(program.GetVP() * m);
+ if (!CullTest(Chunk::Bounds(), mvp)) {
+ chunk.Draw();
+ }