Skip to content

Commit

Permalink
[terrain] geomety optimization takes place before splitting it into t…
Browse files Browse the repository at this point in the history
…iles (avoids seams between tiles)
  • Loading branch information
PanosK92 committed Jan 15, 2025
1 parent edfa685 commit 9b4cc36
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions runtime/World/Components/Terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

//= INCLUDES ============================
//= INCLUDES =============================
#include "pch.h"
#include "Terrain.h"
#include "Renderable.h"
Expand All @@ -31,7 +31,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "../../Rendering/Mesh.h"
#include "../../Core/ThreadPool.h"
#include "../../Core/ProgressTracker.h"
//=======================================
#include "../../Core/GeometryProcessing.h"
//========================================

//= NAMESPACES ===============
using namespace std;
Expand Down Expand Up @@ -578,7 +579,7 @@ namespace spartan
m_is_generating = true;

// star progress tracking
uint32_t job_count = 6;
uint32_t job_count = 7;
ProgressTracker::GetProgress(ProgressType::Terrain).Start(job_count, "Generating terrain...");

uint32_t width = 0;
Expand Down Expand Up @@ -632,14 +633,21 @@ namespace spartan
ProgressTracker::GetProgress(ProgressType::Terrain).JobDone();
}

// 5. split into tiles
// 5. optimize geometry
{
ProgressTracker::GetProgress(ProgressType::Terrain).SetText("Optimizing geometry...");
spartan::geometry_processing::optimize(m_vertices, m_indices);
ProgressTracker::GetProgress(ProgressType::Terrain).JobDone();
}

// 6. split into tiles
{
ProgressTracker::GetProgress(ProgressType::Terrain).SetText("Splitting into tiles...");
split_terrain_into_tiles(m_vertices, m_indices, m_tile_vertices, m_tile_indices);
ProgressTracker::GetProgress(ProgressType::Terrain).JobDone();
}

// 6. create a mesh for each tile
// 7. create a mesh for each tile
{
ProgressTracker::GetProgress(ProgressType::Terrain).SetText("Creating tile meshes");

Expand Down

0 comments on commit 9b4cc36

Please sign in to comment.