Assets/Scripts/MarchingCubesJob.cs
/// <summary>
/// Calculates the cube index of a single voxel
/// </summary>
/// <param name="voxelDensities">The voxel's densities</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 calculated cube index</returns>
Calculates the cube index of a single voxel
Calculates the cube index of a single voxel
[MethodImpl(MethodImplOptions.AggressiveInlining)]
        private int CalculateCubeIndex(VoxelCorners<float> voxelDensities, float isolevel)
        {
            int cubeIndex = 0;
            if (voxelDensities.Corner1 < isolevel) { cubeIndex |= 1; }
            if (voxelDensities.Corner2 < isolevel) { cubeIndex |= 2; }
            if (voxelDensities.Corner3 < isolevel) { cubeIndex |= 4; }
            if (voxelDensities.Corner4 < isolevel) { cubeIndex |= 8; }
            if (voxelDensities.Corner5 < isolevel) { cubeIndex |= 16; }
            if (voxelDensities.Corner6 < isolevel) { cubeIndex |= 32; }
            if (voxelDensities.Corner7 < isolevel) { cubeIndex |= 64; }
            if (voxelDensities.Corner8 < isolevel) { cubeIndex |= 128; }
            return cubeIndex;
        }
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ] private int CalculateCubeIndex ( VoxelCorners < float > voxelDensities , float isolevel ) { int cubeIndex = 0 ; if ( voxelDensities . Corner1 < isolevel ) { cubeIndex |= 1 ; } if ( voxelDensities . Corner2 < isolevel ) { cubeIndex |= 2 ; } if ( voxelDensities . Corner3 < isolevel ) { cubeIndex |= 4 ; } if ( voxelDensities . Corner4 < isolevel ) { cubeIndex |= 8 ; } if ( voxelDensities . Corner5 < isolevel ) { cubeIndex |= 16 ; } if ( voxelDensities . Corner6 < isolevel ) { cubeIndex |= 32 ; } if ( voxelDensities . Corner7 < isolevel ) { cubeIndex |= 64 ; } if ( voxelDensities . Corner8 < isolevel ) { cubeIndex |= 128 ; } return cubeIndex ; }
Calculates the cube index of a single voxel
Calculates the cube index of a single voxel
The calculated cube index
The calculated cube index
voxelDensities
VoxelCorners<float>
The voxel's densities
The voxel ' s densities
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 )