Skip to content

Commit

Permalink
VOXEL: use enum for mesh extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Feb 3, 2024
1 parent 27e8761 commit 9c0333a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/modules/voxelformat/private/mesh/MeshFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ bool MeshFormat::saveGroups(const scenegraph::SceneGraph &sceneGraph, const core
const bool withTexCoords = core::Var::getSafe(cfg::VoxformatWithtexcoords)->boolVal();
const bool applyTransform = core::Var::getSafe(cfg::VoxformatTransform)->boolVal();
const int meshMode = core::Var::getSafe(cfg::VoxelMeshMode)->intVal();
const bool marchingCubes = meshMode == 1;
const voxel::SurfaceExtractionType type = (voxel::SurfaceExtractionType)meshMode;

const glm::vec3 &scale = getScale();
const size_t models = sceneGraph.size(scenegraph::SceneGraphNodeType::AllModels);
Expand All @@ -515,9 +515,10 @@ bool MeshFormat::saveGroups(const scenegraph::SceneGraph &sceneGraph, const core
auto lambda = [&, volume = sceneGraph.resolveVolume(node), region = sceneGraph.resolveRegion(node)]() {
voxel::ChunkMesh *mesh = new voxel::ChunkMesh();
voxel::SurfaceExtractionContext ctx =
marchingCubes ? voxel::buildMarchingCubesContext(volume, region, *mesh, node.palette())
: voxel::buildCubicContext(volume, region, *mesh, glm::ivec3(0), mergeQuads,
reuseVertices, ambientOcclusion);
type == voxel::SurfaceExtractionType::MarchingCubes
? voxel::buildMarchingCubesContext(volume, region, *mesh, node.palette())
: voxel::buildCubicContext(volume, region, *mesh, glm::ivec3(0), mergeQuads, reuseVertices,
ambientOcclusion);
voxel::extractSurface(ctx);
mesh->calculateNormals();
core::ScopedLock scoped(lock);
Expand Down Expand Up @@ -553,7 +554,7 @@ bool MeshFormat::saveGroups(const scenegraph::SceneGraph &sceneGraph, const core
} else {
Log::debug("Save meshes");
state = saveMeshes(meshIdxNodeMap, sceneGraph, nonEmptyMeshes, filename, stream, scale,
marchingCubes ? false : quads, withColor, withTexCoords);
type == voxel::SurfaceExtractionType::Cubic ? quads : false, withColor, withTexCoords);
}
for (MeshExt &meshext : meshes) {
delete meshext.mesh;
Expand Down

0 comments on commit 9c0333a

Please sign in to comment.