-
- Ray aim = controller.Aim();
- Chunk *chunk;
- int blkid;
- float dist;
- glm::vec3 normal;
- if (world.Intersection(aim, glm::mat4(1.0f), &chunk, &blkid, &dist, &normal)) {
- outline_visible = true;
- outline.Clear();
- chunk->Type(chunk->BlockAt(blkid)).FillOutlineModel(outline);
- outline_transform = glm::scale(glm::mat4(1.0f), glm::vec3(1.0002f));
- outline_transform = chunk->Transform(world.Player().ChunkCoords());
- outline_transform *= chunk->ToTransform(blkid);
- } else {
- outline_visible = false;
- }
-
- if (pick) {
- if (chunk) {
- place_id = chunk->BlockAt(blkid).type;
- hud.Display(*world.BlockTypes()[place_id]);
- }
- pick = false;
- }
- if (remove) {
- if (chunk) {
- chunk->BlockAt(blkid).type = remove_id;
- chunk->Invalidate();
- }
- remove = false;
- }
- if (place) {
- if (chunk) {
- Chunk *mod_chunk = chunk;
- glm::vec3 next_pos = Chunk::ToCoords(blkid) + normal;
- if (!Chunk::InBounds(next_pos)) {
- mod_chunk = &world.Next(*chunk, normal);
- next_pos -= normal * glm::vec3(Chunk::Extent());
- }
- mod_chunk->BlockAt(next_pos).type = place_id;
- mod_chunk->Invalidate();
- }
- place = false;
- }