public static MooreCross ClampMin(MooreCross c, float f) { for (int i = 0; i < 9; i++) { c.vals[i] = Mathf.Min(f, c.vals[i]); } return(c); }
public static void CreateTorrents(Matrix heights, Matrix2D <int> order, Matrix torrents) { CoordRect rect = heights.rect; for (int i = 0; i < heights.count; i++) { torrents.arr[i] = 1; //casting initial rain } for (int j = heights.count - 1; j >= 0; j--) { //finding column ordered by height int pos = order.arr[j]; if (pos < 0) { continue; } MooreCross height = new MooreCross(heights.arr, pos, rect.size.x); MooreCross torrent = new MooreCross(torrents.arr, pos, rect.size.x); //moore if (torrent.vals[4] > 200000000) { torrent.vals[4] = 200000000; } MooreCross delta = height.vals[4] - height; delta = MooreCross.ClampMax(delta, 0); MooreCross percents = MooreCross.Zero(); float sum = delta.Sum(); if (sum > 0.00001f) { percents = delta / sum; } MooreCross newTorrent = percents * torrent.vals[4]; newTorrent.AddToMatrix(torrents.arr, pos, rect.size.x); } }
public static void CreateTorrentsRef(float[] heights, int[] order, float[] torrents, CoordRect rect = new CoordRect()) { for (int i = 0; i < heights.Length; i++) { torrents[i] = 1; //casting initial rain } for (int j = heights.Length - 1; j >= 0; j--) { //finding column ordered by height int pos = order[j]; if (pos < 0) { continue; } MooreCross height = new MooreCross(heights, pos, rect.size.x); MooreCross torrent = new MooreCross(torrents, pos, rect.size.x); //moore if (torrent.vals[4] > 200000000) { torrent.vals[4] = 200000000; } MooreCross delta = height.vals[4] - height; delta = MooreCross.ClampMax(delta, 0); MooreCross percents = MooreCross.Zero(); float sum = delta.Sum(); if (sum > 0.00001f) { percents = delta / sum; } MooreCross newTorrent = percents * torrent.vals[4]; newTorrent.AddToMatrix(torrents, pos, rect.size.x); } }
public void Add(MooreCross c2) { c += c2.c; px += c2.px; nx += c2.nx; pz += c2.pz; nz += c2.nz; pxpz += c2.pxpz; nxpz += c2.nxpz; pxnz += c2.pxnz; nxnz += c2.nxnz; }
public MooreCross(MooreCross src) { this.c = src.c; this.px = src.px; this.nx = src.nx; this.pz = src.pz; this.nz = src.nz; this.pxpz = src.pxpz; this.nxpz = src.nxpz; this.pxnz = src.pxnz; this.nxnz = src.nxnz; }