public static void GetHeight(Vector2[] pos, Vector2[] posUV, Vector3[] shore, float[] terrainHeight, float[] waterHeight) { Debug.Assert((int)pos.Length == (int)posUV.Length); Debug.Assert((int)pos.Length == (int)shore.Length); Debug.Assert((int)pos.Length == (int)terrainHeight.Length); Debug.Assert((int)pos.Length == (int)waterHeight.Length); float single = (WaterSystem.Instance != null ? WaterSystem.Ocean.Transform.position.y : 0f); if (TerrainTexturing.Instance != null) { TerrainTexturing.Instance.GetCoarseVectorToShoreArray(posUV, shore); } if (WaterSystem.instance != null) { WaterGerstner.SampleHeightArray(WaterSystem.instance, pos, shore, waterHeight); } for (int i = 0; i < (int)pos.Length; i++) { Vector2 vector2 = posUV[i]; terrainHeight[i] = (TerrainMeta.HeightMap != null ? TerrainMeta.HeightMap.GetHeightFast(vector2) : 0f); float single1 = (TerrainMeta.WaterMap != null ? TerrainMeta.WaterMap.GetHeightFast(vector2) : 0f); if (!(WaterSystem.instance != null) || (double)single1 > (double)single + 0.01) { waterHeight[i] = single1; } else { float single2 = Mathf.Clamp01(Mathf.Abs(single - terrainHeight[i]) * 0.1f); waterHeight[i] *= single2; } } }
public static void GetHeight( Vector2[] pos, Vector2[] posUV, float[] terrainHeight, float[] waterHeight) { Debug.Assert(pos.Length == posUV.Length); Debug.Assert(pos.Length == terrainHeight.Length); Debug.Assert(pos.Length == waterHeight.Length); float num1 = Object.op_Inequality((Object)WaterSystem.Instance, (Object)null) ? (float)(double)WaterSystem.Ocean.Transform.get_position().y : 0.0f; bool flag = Object.op_Inequality((Object)WaterSystem.instance, (Object)null) && WaterSystem.instance.GerstnerWaves != null; if (flag) { WaterGerstner.SampleHeightArray(WaterSystem.instance.GerstnerWaves, pos, waterHeight); } for (int index = 0; index < pos.Length; ++index) { Vector2 uv = posUV[index]; terrainHeight[index] = Object.op_Inequality((Object)TerrainMeta.HeightMap, (Object)null) ? TerrainMeta.HeightMap.GetHeightFast(uv) : 0.0f; float num2 = Object.op_Inequality((Object)TerrainMeta.WaterMap, (Object)null) ? TerrainMeta.WaterMap.GetHeightFast(uv) : 0.0f; if (flag && (double)num2 <= (double)num1 + 0.01) { float num3 = Mathf.Clamp01(Mathf.Abs(num1 - terrainHeight[index]) * 0.1f); waterHeight[index] *= num3; } else { waterHeight[index] = num2; } } }
private void UpdateWaves() { WaterSystem.WaveTime = (this.ProgressTime ? Time.realtimeSinceStartup : WaterSystem.WaveTime); WaterGerstner.UpdatePrecomputedWaves(this.Simulation.OpenSeaWaves, ref this.precomputedWaves); WaterGerstner.UpdatePrecomputedShoreWaves(this.Simulation.ShoreWaves, ref this.precomputedShoreWaves); this.ShoreWavesRcpFadeDistance = 1f / this.Simulation.ShoreWavesFadeDistance; this.TerrainRcpFadeDistance = 1f / this.Simulation.TerrainFadeDistance; }
public static float GetHeight(Vector3 pos, Vector2 posUV, out float terrainHeight) { float num1 = Object.op_Inequality((Object)TerrainMeta.WaterMap, (Object)null) ? TerrainMeta.WaterMap.GetHeightFast(posUV) : 0.0f; float num2 = Object.op_Inequality((Object)WaterSystem.Instance, (Object)null) ? (float)(double)WaterSystem.Ocean.Transform.get_position().y : 0.0f; terrainHeight = Object.op_Inequality((Object)TerrainMeta.HeightMap, (Object)null) ? TerrainMeta.HeightMap.GetHeight(pos) : 0.0f; if (Object.op_Inequality((Object)WaterSystem.instance, (Object)null) && WaterSystem.instance.GerstnerWaves != null && (double)num1 <= (double)num2 + 0.01) { float num3 = Mathf.Clamp01(Mathf.Abs(num2 - terrainHeight) * 0.1f); num1 = WaterGerstner.SampleHeight(WaterSystem.instance.GerstnerWaves, pos) * num3; } return(num1); }
public static float GetHeight(Vector3 pos, Vector2 posUV, out float terrainHeight) { float single = (TerrainMeta.WaterMap != null ? TerrainMeta.WaterMap.GetHeightFast(posUV) : 0f); float single1 = (WaterSystem.Instance != null ? WaterSystem.Ocean.Transform.position.y : 0f); terrainHeight = (TerrainMeta.HeightMap != null ? TerrainMeta.HeightMap.GetHeight(pos) : 0f); if (WaterSystem.instance != null && (double)single <= (double)single1 + 0.01) { Vector3 vector3 = (TerrainTexturing.Instance != null ? TerrainTexturing.Instance.GetCoarseVectorToShore(posUV) : Vector3.zero); float single2 = Mathf.Clamp01(Mathf.Abs(single1 - terrainHeight) * 0.1f); single = WaterGerstner.SampleHeight(WaterSystem.instance, pos, vector3) * single2; } return(single); }
public void GenerateWaves() { this.GerstnerWaves = WaterGerstner.SetupWaves(this.Simulation.Wind, this.Simulation.GerstnerWaves); }