diff options
Diffstat (limited to 'scripts/marching_cubes.gd')
-rw-r--r-- | scripts/marching_cubes.gd | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/scripts/marching_cubes.gd b/scripts/marching_cubes.gd index 6c5296c..cbf278b 100644 --- a/scripts/marching_cubes.gd +++ b/scripts/marching_cubes.gd @@ -12,14 +12,12 @@ class Cell: position.resize(8) value.resize(8) -func march_cube(cell: Cell, triangles: PackedInt32Array, verticies: PackedVector3Array): +func march_cube(cell: Cell, verticies: PackedVector3Array): var cube_index : int = 0 var vertex_list: Array[Vector3] = [] vertex_list.resize(12) - var starting_vertex_count = verticies.size() - for i in 8: if cell.value[i] < 0: cube_index |= (1 << i) @@ -66,16 +64,12 @@ func march_cube(cell: Cell, triangles: PackedInt32Array, verticies: PackedVector local_remap[mc._tri_table[cube_index][tri_index]] = new_vertex_count new_vertex_count += 1 tri_index += 1 - - for i in new_vertex_count: - var vert = new_vertex_list[i] - verticies.push_back(vert) tri_index = 0 while mc._tri_table[cube_index][tri_index] != -1: - triangles.push_back(local_remap[mc._tri_table[cube_index][tri_index + 0]] + starting_vertex_count) - triangles.push_back(local_remap[mc._tri_table[cube_index][tri_index + 1]] + starting_vertex_count) - triangles.push_back(local_remap[mc._tri_table[cube_index][tri_index + 2]] + starting_vertex_count) + verticies.push_back(new_vertex_list[local_remap[mc._tri_table[cube_index][tri_index + 0]]]) + verticies.push_back(new_vertex_list[local_remap[mc._tri_table[cube_index][tri_index + 1]]]) + verticies.push_back(new_vertex_list[local_remap[mc._tri_table[cube_index][tri_index + 2]]]) tri_index += 3 |