using Sandbox.Definitions; using System; using VRage.Game.Components; using VRage.Utils; namespace michi84o.NotSoSmoothVoxels { [MySessionComponentDescriptor(MyUpdateOrder.NoUpdate)] public class MyNotSoSmoothVoxels : MySessionComponentBase { public override void LoadData() { try { int cnt = 0; foreach (MyPlanetGeneratorDefinition planet in MyDefinitionManager.Static.GetPlanetsGeneratorsDefinitions()) { if(planet.Detail != null) { ++cnt; // What Smooth Voxels did: //planet.Detail = null; //continue; // Some info about surface detail: // planet.Detail.Size : This is never read in VRage2 source code! // planet.Detail.Transition : This is an angle in degrees and is used with the slope range // Probably the width of the transition // Decreasing transition makes voxel even more rough // planet.Detail.Slope.Min : Min Slope in degrees // planet.Detail.Slope.Max : Max Slope in degrees /* What VRage does: Init: Size = def.Size; Factor = faceSize / Size; m_min = (float)Math.Cos(MathHelper.ToRadians(def.Slope.Max)); m_max = (float)Math.Cos(MathHelper.ToRadians(def.Slope.Min)); m_in = (float)Math.Cos(MathHelper.ToRadians(def.Slope.Max - def.Transition)); LOOK AT THIS m_out = (float)Math.Cos(MathHelper.ToRadians(def.Slope.Min + def.Transition)); LOOK AT THIS m_inRecip = 1f / (m_in - m_min); m_outRecip = 1f / (m_max - m_out); m_mid = (float)Math.Cos(MathHelper.ToRadians((def.Slope.Max + def.Slope.Min) / 2f)); Scale = def.Scale; GetValue: public float GetValue(float dtx, float dty, float angle) { if (m_detail == null) return 0f; float num = ((!(angle > m_mid)) ? Math.Max(Math.Min((angle - m_in) * m_inRecip, 1f), 0f) : Math.Min(Math.Max(1f - (angle - m_out) * m_outRecip, 0f), 1f)); return m_detail.GetValue(dtx, dty) * num * Scale; } */ if (planet.Detail.Slope.Min < 35) planet.Detail.Slope.Min = 35f; planet.Detail.Scale *= .75f; planet.Detail.Transition = (float)((planet.Detail.Slope.Max-planet.Detail.Slope.Min)/3); } } MyLog.Default.WriteLine("[NotSoSmoothVoxels] Modified " + cnt + " planet definitions."); } catch (Exception ex) { MyLog.Default.WriteLine("[NotSoSmoothVoxels] Oops: " + ex.Message); } } } }