public NOISE_LAYER(NoiseData _noiseData, FLOAT2 _seed, bool _seedIgnore, bool _islandMode) { noiseData = _noiseData; seed = _seed; seedIgnore = _seedIgnore; islandMode = _islandMode; }
public static int2 PointToIndex2d(FLOAT2 point, FLOAT2 worldSize, INT width, INT height) { GetPositionInsideCell(point, new int2 { x = width, y = height }, worldSize, out int2 lo, out int2 hi, out float2 f); int2 index = new int2 { x = AboutEqual(f.x, 1f) ? hi.x : lo.x, y = AboutEqual(f.y, 1f) ? hi.y : lo.y }; return(math.clamp(index, 0, new int2 { x = width - 1, y = height - 1 })); }
public static void GetPositionInsideCell ( FLOAT2 point, INT2 numCells, FLOAT2 worldSize, out int2 lowerCell, out int2 upperCell, out float2 normalizedPositionBetweenThoseTwoPoints ) { GetPositionInsideCell(point.x, numCells.x, worldSize.x, out int xlo, out int xhi, out float xf); GetPositionInsideCell(point.y, numCells.y, worldSize.y, out int ylo, out int yhi, out float yf); lowerCell = new int2 { x = xlo, y = ylo }; upperCell = new int2 { x = xhi, y = yhi }; normalizedPositionBetweenThoseTwoPoints = new float2 { x = xf, y = yf }; }
public static FLOAT2 F2Scale( FLOAT2 In, float Scale ) { FLOAT2 Result ; Result.u = In.u * Scale ; Result.v = In.v * Scale ; return Result ; }
public static FLOAT2 F2Sub( FLOAT2 In1, FLOAT2 In2 ) { FLOAT2 Result ; Result.u = In1.u - In2.u ; Result.v = In1.v - In2.v ; return Result ; }
public static FLOAT2 F2Add( FLOAT2 In1, FLOAT2 In2 ) { FLOAT2 Result ; Result.u = In1.u + In2.u ; Result.v = In1.v + In2.v ; return Result ; }
/// <summary> Value at point </summary> public static T PointToValue <T> (FLOAT2 point, FLOAT2 worldSize, NativeArray <T> array, INT width, INT height) where T : unmanaged { return(array[PointToIndex(point, worldSize, width, height)]); }
public static float2 Index2dToPoint(INT2 i2, FLOAT2 step) => Index2dToPoint(i2.x, i2.y, step.x, step.y);
/// <summary> System.Math.Round( value, System.MidpointRounding.AwayFromZero ) equivalent </summary> public static float2 MidpointRoundingAwayFromZero(FLOAT2 value, FLOAT2 step) => (float2)MidpointRoundingAwayFromZero(value / step) * (float2)step;
/// <summary> System.Math.Round( value , System.MidpointRounding.AwayFromZero ) equivalent </summary> public static int2 MidpointRoundingAwayFromZero(FLOAT2 value) => new int2 { x = MidpointRoundingAwayFromZero(value.x), y = MidpointRoundingAwayFromZero(value.y) };
public static float2 Index2dToPoint(INT2 i2, FLOAT2 step) => NativeGrid.Index2dToPoint(i2, step);
public static float DotProduct(FLOAT2 a, FLOAT2 b) { return(a.X * b.X + a.Y * b.Y); }
/// <summary> Index from point </summary> public static int PointToIndex(FLOAT2 point, FLOAT2 worldSize, INT width, INT height) { int2 xy = PointToIndex2d(point, worldSize, width, height); return(Index2dTo1d(xy, width)); }
public static float2 MidpointRoundingAwayFromZero(FLOAT2 value, FLOAT2 step) => NativeGrid.MidpointRoundingAwayFromZero(value, step);
public static int2 MidpointRoundingAwayFromZero(FLOAT2 value) => NativeGrid.MidpointRoundingAwayFromZero(value);
public static void GetPositionInsideCell(FLOAT2 point, INT2 numCells, FLOAT2 worldSize, out int2 lowerCell, out int2 upperCell, out float2 normalizedPositionBetweenThoseTwoPoints) => NativeGrid.GetPositionInsideCell(point, numCells, worldSize, out lowerCell, out upperCell, out normalizedPositionBetweenThoseTwoPoints);
public static int2 PointToIndex2d(FLOAT2 point, FLOAT2 worldSize, INT width, INT height) => NativeGrid.PointToIndex2d(point, worldSize, width, height);
public static T PointToValue <T> (FLOAT2 point, FLOAT2 worldSize, NativeArray <T> array, INT width, INT height) where T : unmanaged => NativeGrid.PointToValue <T>(point, worldSize, array, width, height);