Skip to content

Commit

Permalink
Adds linear Grow curve
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed May 29, 2014
1 parent bac0e65 commit b532881
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ModelMultiParticlePersistFX.cs
Expand Up @@ -130,6 +130,8 @@ public class ModelMultiParticlePersistFX : EffectBehaviour
// (Log(logarithmicGrowth * t + 1) + 1) * initialSize, assuming grow = 0.
public MultiInputCurve logGrow;

public MultiInputCurve linGrow;

// Those 2 curve are related to the angle and distance to cam
public FXCurve angle = new FXCurve("angle", 1f);

Expand Down Expand Up @@ -376,6 +378,8 @@ public void UpdateEmitters(float power)

pkpe.logarithmicGrow = logGrow.Value(inputs);

pkpe.linearGrow = linGrow.Value(inputs);

pkpe.go.transform.localPosition = localPosition
+ offsetDirection.normalized * offset.Value(inputs) * fixedScale;

Expand Down Expand Up @@ -536,6 +540,7 @@ public override void OnLoad(ConfigNode node)
offset = new MultiInputCurve("offset", true);
force = new MultiInputCurve("force", true);
logGrow = new MultiInputCurve("logGrow", true);
linGrow = new MultiInputCurve("linGrow", true);

ConfigNode.LoadObjectFromConfig(this, node);
emission.Load(node);
Expand All @@ -548,6 +553,7 @@ public override void OnLoad(ConfigNode node)
force.Load(node);

logGrow.Load(node);
linGrow.Load(node);

angle.Load("angle", node);
distance.Load("distance", node);
Expand All @@ -565,6 +571,7 @@ public override void OnSave(ConfigNode node)
offset.Save(node);
force.Save(node);
logGrow.Save(node);
linGrow.Save(node);

angle.Save(node);
distance.Save(node);
Expand Down Expand Up @@ -728,6 +735,7 @@ private float minInput(int id)
min = Mathf.Min(min, offset.minInput[id]);
min = Mathf.Min(min, force.minInput[id]);
min = Mathf.Min(min, logGrow.minInput[id]);
min = Mathf.Min(min, linGrow.minInput[id]);

return min;
}
Expand All @@ -743,6 +751,7 @@ private float maxInput(int id)
max = Mathf.Max(max, offset.maxInput[id]);
max = Mathf.Max(max, force.maxInput[id]);
max = Mathf.Max(max, logGrow.maxInput[id]);
max = Mathf.Max(max, linGrow.maxInput[id]);

return max;
}
Expand Down
6 changes: 6 additions & 0 deletions PersistentKSPParticleEmitter.cs
Expand Up @@ -72,6 +72,8 @@ public class PersistentKSPParticleEmitter

public float logarithmicGrow;

public float linearGrow;

public float sizeClamp = 50;

// The initial velocity of the particles will be offset by a random amount
Expand Down Expand Up @@ -224,6 +226,10 @@ public void EmitterOnUpdate(Vector3 emitterWorldVelocity)
(((TimeWarp.fixedDeltaTime * this.logarithmicGrow)
/ (1 + (particle.startEnergy - particle.energy) * this.logarithmicGrow)) * averageSize);
}
if (this.linearGrow != 0.0)
{
particle.size += (float)(TimeWarp.fixedDeltaTime * this.linearGrow * averageSize);
}

particle.size = Mathf.Min(particle.size, this.sizeClamp);

Expand Down

0 comments on commit b532881

Please sign in to comment.