Skip to content

Commit

Permalink
underground terrain
Browse files Browse the repository at this point in the history
  • Loading branch information
todorico committed Jan 13, 2020
1 parent 6deab6d commit ab776ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/components/terrainModificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ TerrainModificator::TerrainModificator(){
setName("Terrain Modificator");
}

void TerrainModificator::destroy(size_t radius)
{
setSphere(m_gameobject->getTransform()->getPosition(), radius, Voxel::Empty);
}

void TerrainModificator::setSphere(glm::vec3 world_coord, size_t radius, Voxel v) {
glm::vec3 min_coord = world_coord - glm::vec3(radius);

Expand All @@ -29,7 +34,10 @@ void TerrainModificator::setSphere(glm::vec3 world_coord, size_t radius, Voxel v
}
}

void inputUpdate(){
void TerrainModificator::inputUpdate(){

glm::vec3 pos = m_gameobject->getTransform()->getPosition();

if(ImGui::IsKeyPressed('O'))
setSphere(pos, 10, Voxel::Empty);
else if (ImGui::IsKeyPressed('U'))
Expand Down
4 changes: 3 additions & 1 deletion src/components/terrainModificator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ class TerrainModificator : public Component {

TerrainModificator();

void inputUpdate() override;
void createUI() override;

void setSphere(glm::vec3 position, size_t size, Voxel v);
void destroy(size_t radius);
void setSphere(glm::vec3 position, size_t radius, Voxel v);

void setTerrain(TerrainManager *terrain){m_terrain = terrain;}

Expand Down

0 comments on commit ab776ed

Please sign in to comment.