OverviewFilesCommitsIssuesDocsReleasesPeers

dc-terrain / libdc / include / dc_mesher.h

35 lines · c ref:
#ifndef DC_MESHER_H
#define DC_MESHER_H

// Convenience API: fill a density grid from a DCGenerator and run
// the full Dual Contouring pipeline (octree → QEF → contour → post-process).
// Pure C++ — no Godot dependencies.

#include "dc_contour.h"
#include "dc_density_grid.h"
#include "dc_generator.h"

struct DCMesherConfig {
    bool auto_smooth = true;
    float smooth_angle_deg = 30.0f;
    bool laplacian_smooth = false;
    int laplacian_iterations = 2;
    float laplacian_lambda = 0.5f;
    float qef_bias = 0.01f;
    bool clip_to_bounds = true;
};

// Mesh a pre-filled density grid using Dual Contouring.
// Grid must have density data filled and normals computed.
DCMeshData dc_mesh_from_grid(const DensityGrid& grid, const DCMesherConfig& config);

// Fill grid from generator, then mesh. Allocates grid internally.
// origin: world-space corner of the grid volume
// voxel_size: world units per voxel
// grid_size: number of voxels per axis (grid will be grid_size+1 samples)
DCMeshData dc_mesh_from_generator(DCGenerator& gen, const float origin[3],
                                   float voxel_size, int grid_size,
                                   const DCMesherConfig& config);

#endif // DC_MESHER_H