protected override void ThreadFunction() { try { Request r = new Request(); if (_numberSampler == null) { return; } for (var x = _startX; x < _startX + Width; x++) { for (var z = _startZ; z < _startZ + Height; z++) { r.X = x; r.Z = z; float v = _numberSampler.GetNumber(_numberSamplerRequestSocket, r); if (float.IsNaN(ResultLowestValue) || ResultLowestValue > v) { ResultLowestValue = v; } if (float.IsNaN(ResultHighestValue) || ResultHighestValue < v) { ResultHighestValue = v; } _values[x - _startX, z - _startZ] = v; } } } catch (Exception e) { Debug.Log(e.Message + "\n" + e.StackTrace); } }
protected override void ThreadFunction() { Request r = new Request(); if (_numberSampler == null) { return; } for (var x = _startX; x < _startX + Width; x++) { for (var y = _startZ; y < _startZ + Height; y++) { r.X = x; float v = _numberSampler.GetNumber(_numberSamplerRequestSocket, r); if (float.IsNaN(ResultLowestValue) || ResultLowestValue > v) { ResultLowestValue = v; } if (float.IsNaN(ResultHighestValue) || ResultHighestValue < v) { ResultHighestValue = v; } float relativeHeight = (v + 1) / 2f * Height; if (relativeHeight > y) { _values[x, y] = y / (float)Height * 2 - 1; } else { _values[x, y] = float.NaN; } } } }
public static float GetInputNumber(InputSocket socket, Request request) { if (socket.IsInDirectInputMode()) { return(socket.GetDirectInputNumber()); } if (!socket.IsConnected()) { return(float.NaN); } INumberConnection sampler = socket.GetConnectedSocket().Parent as INumberConnection; if (sampler == null) { return(float.NaN); } return(sampler.GetNumber(socket.GetConnectedSocket(), request)); }