Skip to content

Commit

Permalink
Fix the problem with engine over 750 m/s, adds a force curve
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed May 19, 2014
1 parent 9bc6580 commit 74703ad
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
22 changes: 16 additions & 6 deletions ModelMultiParticlePersistFX.cs
Expand Up @@ -120,6 +120,8 @@ public class ModelMultiParticlePersistFX : EffectBehaviour

public MultiInputCurve offset;

public MultiInputCurve force;

// Logarithmic growth applied to to the particle.
// The size at time t after emission will be approximately
// (Log(logarithmicGrowth * t + 1) + 1) * initialSize, assuming grow = 0.
Expand Down Expand Up @@ -394,10 +396,9 @@ public void FixedUpdate()
}
finally
{
particles[j].velocity = (persistentEmitters[i].pe.useWorldSpace
? (Vector3)pVel
: persistentEmitters[i].pe.transform.InverseTransformDirection(
pVel)) - Krakensbane.GetFrameVelocity();
particles[j].velocity = (persistentEmitters[i].pe.useWorldSpace ?
(Vector3)(pVel - Krakensbane.GetFrameVelocity()) :
persistentEmitters[i].pe.transform.InverseTransformDirection(pVel - Krakensbane.GetFrameVelocity()));
particles[j].position = persistentEmitters[i].pe.useWorldSpace
? (Vector3)pPos
: persistentEmitters[i].pe.transform.InverseTransformPoint(pPos);
Expand Down Expand Up @@ -620,8 +621,12 @@ public void UpdateEmitters(float power)
pkpe.pe.minEnergy = pkpe.minEnergyBase * energyPower;
pkpe.pe.maxEnergy = pkpe.maxEnergyBase * energyPower;

float localVelocityPower = speed.Value(inputs);
pkpe.pe.localVelocity = pkpe.localVelocityBase * localVelocityPower;
float velocityPower = speed.Value(inputs);
pkpe.pe.localVelocity = pkpe.localVelocityBase * velocityPower;
pkpe.pe.worldVelocity = pkpe.worldVelocityBase * velocityPower;

float forcePower = force.Value(inputs);
pkpe.pe.force = pkpe.forceBase * forcePower;

pkpe.pe.sizeGrow = grow.Value(inputs);

Expand Down Expand Up @@ -786,6 +791,7 @@ public override void OnLoad(ConfigNode node)
scale = new MultiInputCurve("scale");
size = new MultiInputCurve("size");
offset = new MultiInputCurve("offset", true);
force = new MultiInputCurve("force", true);
logGrow = new MultiInputCurve("logGrow", true);

ConfigNode.LoadObjectFromConfig(this, node);
Expand All @@ -796,6 +802,7 @@ public override void OnLoad(ConfigNode node)
scale.Load(node);
size.Load(node);
offset.Load(node);
force.Load(node);

logGrow.Load(node);

Expand All @@ -813,6 +820,7 @@ public override void OnSave(ConfigNode node)
scale.Save(node);
size.Save(node);
offset.Save(node);
force.Save(node);
logGrow.Save(node);

angle.Save(node);
Expand Down Expand Up @@ -968,6 +976,7 @@ private float minInput(int id)
min = Mathf.Min(min, scale.minInput[id]);
min = Mathf.Min(min, size.minInput[id]);
min = Mathf.Min(min, offset.minInput[id]);
min = Mathf.Min(min, force.minInput[id]);
min = Mathf.Min(min, logGrow.minInput[id]);

return min;
Expand All @@ -982,6 +991,7 @@ private float maxInput(int id)
max = Mathf.Max(max, scale.maxInput[id]);
max = Mathf.Max(max, size.maxInput[id]);
max = Mathf.Max(max, offset.maxInput[id]);
max = Mathf.Max(max, force.maxInput[id]);
max = Mathf.Max(max, logGrow.maxInput[id]);

return max;
Expand Down
7 changes: 7 additions & 0 deletions PersistentKSPParticleEmitter.cs
Expand Up @@ -58,6 +58,10 @@ public class PersistentKSPParticleEmitter

public readonly Vector3 localVelocityBase;

public readonly Vector3 worldVelocityBase;

public readonly Vector3 forceBase;

public PersistentKSPParticleEmitter(
GameObject go,
KSPParticleEmitter pe,
Expand All @@ -79,6 +83,9 @@ public class PersistentKSPParticleEmitter
maxSizeBase = (float)templateKspParticleEmitter.maxSize;

localVelocityBase = templateKspParticleEmitter.localVelocity;
worldVelocityBase = templateKspParticleEmitter.worldVelocity;

forceBase = templateKspParticleEmitter.force;

PersistentEmitterManager.Add(this);
}
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Expand Up @@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
2 changes: 1 addition & 1 deletion SmokeScreenUtil.cs
Expand Up @@ -38,7 +38,7 @@ static class SmokeScreenUtil
public static string WriteRootNode(ConfigNode node)
{
StringBuilder builder = new StringBuilder();
print("node.values.Count " + node.values.Count + " node.nodes.Count " + node.nodes.Count);
//print("node.values.Count " + node.values.Count + " node.nodes.Count " + node.nodes.Count);
for (int i = 0; i < node.values.Count; i++)
{
ConfigNode.Value item = node.values[i];
Expand Down

0 comments on commit 74703ad

Please sign in to comment.