Skip to content

Commit

Permalink
properly swizzle coords for volume grid isosurface marching cubes, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nmwsharp committed Mar 28, 2024
1 parent f694632 commit 5d0bb5e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/volume_grid_scalar_quantity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ void VolumeGridNodeScalarQuantity::createIsosurfaceProgram() {
// Transform the result to be aligned with our volume's spatial layout
glm::vec3 scale = parent.gridSpacing();
for (auto& p : isosurfaceMesh.vertices) {
p = p * scale + parent.getBoundMin();
// swizzle to account for change of coordinate/buffer ordering in the MC lib
p = glm::vec3{p.z, p.y, p.x} * scale + parent.getBoundMin();
}

std::vector<std::string> isoProgramRules{"SHADE_BASECOLOR", "PROJ_AND_INV_PROJ_MAT",
Expand Down Expand Up @@ -218,7 +219,8 @@ SurfaceMesh* VolumeGridNodeScalarQuantity::registerIsosurfaceAsMesh(std::string
parent.getGridNodeDim().z, isosurfaceMesh);
glm::vec3 scale = parent.gridSpacing();
for (auto& p : isosurfaceMesh.vertices) {
p = p * scale + parent.getBoundMin();
// swizzle to account for change of coordinate/buffer ordering in the MC lib
p = glm::vec3{p.z, p.y, p.x} * scale + parent.getBoundMin();
}

return registerSurfaceMesh(structureName, isosurfaceMesh.vertices,
Expand Down

0 comments on commit 5d0bb5e

Please sign in to comment.