Skip to content

Commit

Permalink
IsoSurface level
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiboo committed Jan 11, 2019
1 parent 1ae49a4 commit 7980dc8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.cadiboo.nocubes.mesh.generator;

import io.github.cadiboo.nocubes.config.ModConfig;
import io.github.cadiboo.nocubes.mesh.IMeshGenerator;
import io.github.cadiboo.nocubes.util.Face;
import io.github.cadiboo.nocubes.util.Vec3;
Expand Down Expand Up @@ -98,6 +99,7 @@ public Map<int[], ArrayList<Face<Vec3>>> generateChunk(final float[] data, final

final HashMap<int[], ArrayList<Face<Vec3>>> posToFaces = new HashMap<>();
final ArrayList<Face<Vec3>> faces = new ArrayList<>();
final float isosurfaceLevel = ModConfig.getIsosurfaceLevel();

//March over the voxel grid
for (x[2] = 0; x[2] < dims[2] - 1; ++x[2], n += dims[0], buf_no ^= 1, R[2] = -R[2]) {
Expand Down Expand Up @@ -170,7 +172,7 @@ public Map<int[], ArrayList<Face<Vec3>>> generateChunk(final float[] data, final
}

//Now we just average the edge intersections and add them to coordinate
float s = 1F / e_count;
float s = isosurfaceLevel / e_count;
for (int i = 0; i < 3; ++i) {
v[i] = x[i] + s * v[i];
}
Expand Down

0 comments on commit 7980dc8

Please sign in to comment.