Assets/Scripts/MarchingCubesJob.cs
/// <summary>
/// Generates the vertex list for a single voxel
/// </summary>
/// <param name="voxelDensities">The voxel's densities</param>
/// <param name="voxelCorners">The voxel's corners</param>
/// <param name="edgeIndex">The edge index</param>
/// <param name="isolevel">The density level where a surface will be created. Densities below this will be inside the surface (solid),
/// and densities above this will be outside the surface (air)</param>
/// <returns>The generated vertex list for the voxel</returns>
Generates the vertex list for a single voxel
Generates the vertex list for a single voxel
[MethodImpl(MethodImplOptions.AggressiveInlining)]
        private VertexList GenerateVertexList(VoxelCorners<float> voxelDensities, VoxelCorners<int3> voxelCorners,
            int edgeIndex, float isolevel)
        {
            var vertexList = new VertexList();
            for (int i = 0; i < 12; i++)
            {
                if ((edgeIndex & (1 << i)) == 0) { continue; }
                int edgeStartIndex = LookupTables.EdgeIndexTable[2*i+0];
                int edgeEndIndex = LookupTables.EdgeIndexTable[2*i+1];
                int3 corner1 = voxelCorners[edgeStartIndex];
                int3 corner2 = voxelCorners[edgeEndIndex];
                float density1 = voxelDensities[edgeStartIndex];
                float density2 = voxelDensities[edgeEndIndex];
                vertexList[i] = VertexInterpolate(corner1, corner2, density1, density2, isolevel);
            }
            return vertexList;
        }
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ] private VertexList GenerateVertexList ( VoxelCorners < float > voxelDensities , VoxelCorners < int3 > voxelCorners , int edgeIndex , float isolevel ) { var vertexList = new VertexList ( ) ; for ( int i = 0 ; i < 12 ; i ++ ) { if ( ( edgeIndex & ( 1 << i ) ) == 0 ) { continue ; } int edgeStartIndex = LookupTables . EdgeIndexTable [ 2 * i + 0 ] ; int edgeEndIndex = LookupTables . EdgeIndexTable [ 2 * i + 1 ] ; int3 corner1 = voxelCorners [ edgeStartIndex ] ; int3 corner2 = voxelCorners [ edgeEndIndex ] ; float density1 = voxelDensities [ edgeStartIndex ] ; float density2 = voxelDensities [ edgeEndIndex ] ; vertexList [ i ] = VertexInterpolate ( corner1 , corner2 , density1 , density2 , isolevel ) ; } return vertexList ; }
Generates the vertex list for a single voxel
Generates the vertex list for a single voxel
The generated vertex list for the voxel
The generated vertex list for the voxel
voxelDensities
VoxelCorners<float>
The voxel's densities
The voxel ' s densities
voxelCorners
VoxelCorners<int3>
The voxel's corners
The voxel ' s corners
edgeIndex
int
The edge index
The edge index
isolevel
float
The density level where a surface will be created. Densities below this will be inside the surface (solid),
and densities above this will be outside the surface (air)
The density level where a surface will be created . Densities below this will be inside the surface ( solid ) and densities above this will be outside the surface ( air )