private static void ProcessDetails(Dictionary <int, int[, ]> details, DslExpression.DslCalculator calc, string proc, int x, int y, int w, int h) { for (int ix = 0; ix < w; ++ix) { for (int iy = 0; iy < h; ++iy) { int xi = x + ix; int yi = y + iy; foreach (var pair in details) { int layer = pair.Key; var detail = pair.Value[xi, yi]; calc.SetGlobalVariable("detail", detail); calc.Calc(proc, xi, yi, layer); pair.Value[xi, yi] = calc.GetGlobalVariable("detail").Get <int>(); } } if (DisplayCancelableProgressBar("生成detail数据", ix * h, w * h)) { goto quit; } } quit: EditorUtility.ClearProgressBar(); }
private static void ProcessHeights(float[,] datas, DslExpression.DslCalculator calc, string proc, int cx, int cy, int r) { int x = cx - r; int y = cy - r; int w = r * 2; int h = r * 2; int r2 = r * r; for (int ix = 0; ix < w; ++ix) { for (int iy = 0; iy < h; ++iy) { int xi = x + ix; int yi = y + iy; int dx = xi - cx; int dy = yi - cy; if (dx * dx + dy * dy <= r2) { calc.SetGlobalVariable("height", datas[yi, xi]); calc.Calc(proc, xi, yi); datas[yi, xi] = calc.GetGlobalVariable("height").Get <float>(); } } if (DisplayCancelableProgressBar("生成高度与对象数据", ix * h, w * h)) { goto quit; } } quit: EditorUtility.ClearProgressBar(); }
private static void ProcessAlphamaps(float[,,] alphamaps, DslExpression.DslCalculator calc, string proc, int x, int y, int w, int h) { int alphanum = alphamaps.GetLength(2); for (int ix = 0; ix < w; ++ix) { for (int iy = 0; iy < h; ++iy) { int xi = x + ix; int yi = y + iy; float[] alphas = calc.GetGlobalVariable("alphas").As <float[]>(); for (int i = 0; i < alphanum; ++i) { alphas[i] = alphamaps[xi, yi, i]; } var v = calc.Calc(proc, xi, yi); for (int i = 0; i < alphanum; ++i) { alphamaps[xi, yi, i] = alphas[i]; } } if (DisplayCancelableProgressBar("生成alphamap数据", ix * h, w * h)) { goto quit; } } quit: EditorUtility.ClearProgressBar(); }
private static void ProcessHeights(float[,] datas, DslExpression.DslCalculator calc, string proc, int x, int y, int w, int h) { for (int ix = 0; ix < w; ++ix) { for (int iy = 0; iy < h; ++iy) { int xi = x + ix; int yi = y + iy; calc.SetGlobalVariable("height", datas[yi, xi]); calc.Calc(proc, xi, yi); datas[yi, xi] = calc.GetGlobalVariable("height").Get <float>(); } if (DisplayCancelableProgressBar("生成高度与对象数据", ix * h, w * h)) { goto quit; } } quit: EditorUtility.ClearProgressBar(); }