public float ComputeBlend(BiomeBlendList blendMatrix, BiomeParamRange param, BiomeSwitchValues values, float blendPercent) { float blend = 0; float blendParamCount = 0; int length = values.length; for (int i = 0; i < length; i++) { if (!blendMatrix.blendEnabled[i] || !switchParams.switchParams[i].enabled || !values.enabled[i]) { continue; } //Compute biome blend using blendPercent float v = values.switchValues[i]; float min = switchParams.switchParams[i].min; float max = switchParams.switchParams[i].max; float mag = max - min; float p = mag * blendPercent; if (mag == 0) { continue; } float b = 0; if (v < min && v > min - p) { b = .5f + (((v - min) / p) / 2); } if (v > max && v < max + p) { b = .5f - (((v - max) / p) / 2); } blend += b; if (debug) { Debug.Log("i: " + i + "blend range: " + min + " to " + max + ", mag: " + mag + ", val: " + v + ", blend percent range: " + p + ", blend: " + b); } if (b > 0) { blendParamCount++; } } return((blendParamCount == 0) ? 0 : blend / blendParamCount); }
public bool Matches(BiomeSwitchValues bsv) { var switchValues = bsv.switchValues; for (int i = 0; i < switchValues.Length; i++) { var p = this.switchParams.switchParams[i]; if (p.enabled && (switchValues[i] < p.min || switchValues[i] > p.max)) { return(false); } } return(true); }