/* Original source Farseer Physics Engine: * Copyright (c) 2014 Ian Qvist, http://farseerphysics.codeplex.com * Microsoft Permissive License (Ms-PL) v1.1 */ using nkast.Aether.Physics2D.Common; namespace tainicom.Aether.Physics2D.Fluids { /// /// Fluid parameters, see pvfs.pdf for a detailed explanation /// public struct FluidDefinition { /// /// Distance of influence between the particles /// public float InfluenceRadius; /// /// Density of the fluid /// public float DensityRest; /// /// Stiffness of the fluid (when particles are far) /// public float Stiffness; /// /// Stiffness of the fluid (when particles are near) /// Set by Check() /// public float StiffnessNear; /// /// Toggles viscosity forces /// public bool UseViscosity; /// /// See pvfs.pdf for more information /// public float ViscositySigma; /// /// See pvfs.pdf for more information /// public float ViscosityBeta; /// /// Toggles plasticity computation (springs etc.) /// public bool UsePlasticity; /// /// Plasticity, amount of memory of the shape /// See pvfs.pdf for more information /// public float Plasticity; /// /// K of the springs used for plasticity /// public float KSpring; /// /// Amount of change of the rest length of the springs (when compressed) /// public float YieldRatioCompress; /// /// Amount of change of the rest length of the springs (when stretched) /// public float YieldRatioStretch; public static FluidDefinition Default { get { FluidDefinition def = new FluidDefinition { InfluenceRadius = 1.0f, DensityRest = 10.0f, Stiffness = 10.0f, StiffnessNear = 0.0f, // Set by Check() UseViscosity = false, ViscositySigma = 10.0f, ViscosityBeta = 0.0f, UsePlasticity = false, Plasticity = 0.3f, KSpring = 2.0f, YieldRatioCompress = 0.1f, YieldRatioStretch = 0.1f }; def.Check(); return def; } } public void Check() { InfluenceRadius = MathUtils.Clamp(InfluenceRadius, 0.1f, 10.0f); DensityRest = MathUtils.Clamp(DensityRest, 1.0f, 100.0f); Stiffness = MathUtils.Clamp(Stiffness, 0.1f, 10.0f); StiffnessNear = Stiffness * 100.0f; // See pvfs.pdf ViscositySigma = Math.Max(ViscositySigma, 0.0f); ViscosityBeta = Math.Max(ViscosityBeta, 0.0f); Plasticity = Math.Max(Plasticity, 0.0f); KSpring = Math.Max(KSpring, 0.0f); YieldRatioCompress = Math.Max(YieldRatioCompress, 0.0f); YieldRatioStretch = Math.Max(YieldRatioStretch, 0.0f); } } }