Skip to content

Commit

Permalink
Minor tweak / xyzForce bugfix
Browse files Browse the repository at this point in the history
Removed redundant if statement, fixed xyForce and zForce being flagged
as additive and not multiplicative.
  • Loading branch information
Felger committed Jul 7, 2015
1 parent 51df82f commit 36e76fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ModelMultiParticlePersistFX.cs
Expand Up @@ -630,8 +630,8 @@ public override void OnLoad(ConfigNode node)
initalVelocityOffsetMaxRadius = new MultiInputCurve("initalVelocityOffsetMaxRadius", true);
sizeClampCurve = new MultiInputCurve("sizeClamp", true);
randConeEmit = new MultiInputCurve("randConeEmit", true);
xyForce = new MultiInputCurve("xyForce", true);
zForce = new MultiInputCurve("zForce", true);
xyForce = new MultiInputCurve("xyForce", false);
zForce = new MultiInputCurve("zForce", false);

ConfigNode.LoadObjectFromConfig(this, node);
emission.Load(node);
Expand Down
37 changes: 17 additions & 20 deletions PersistentKSPParticleEmitter.cs
Expand Up @@ -230,28 +230,25 @@ public void EmitterOnUpdate(Vector3 emitterWorldVelocity)
else if (!pe.useWorldSpace && particle.energy == particle.startEnergy && (randConeEmit != 0))
{
Vector3 lVel = new Vector3(0, 0, 1); ;
if (randConeEmit != 0)
// Adjust initial velocity to make a cone. Only perform if pe.useWorldSpace
// is true, and we have a randConeEmit set.
//Produce a random vector within "angle" of the original vector.
//The maximum producible cone is 90 degrees when randConeEmit is very large.
//Could open up more if we used trig, but it'd be less efficient.
if (coneToggle)
{
// Adjust initial velocity to make a cone. Only perform if pe.useWorldSpace
// is true, and we have a randConeEmit set.
//Produce a random vector within "angle" of the original vector.
//The maximum producible cone is 90 degrees when randConeEmit is very large.
//Could open up more if we used trig, but it'd be less efficient.
if (coneToggle)
{
disk = Random.insideUnitCircle * randConeEmit;
coneToggle = false;
}
else
{
disk *= -1;
coneToggle = true;
}
lVel.x = disk.x;
lVel.y = disk.y;
lVel = Vector3.Normalize(lVel);
lVel *= Vector3.Magnitude(particle.velocity);
disk = Random.insideUnitCircle * randConeEmit;
coneToggle = false;
}
else
{
disk *= -1;
coneToggle = true;
}
lVel.x = disk.x;
lVel.y = disk.y;
lVel = Vector3.Normalize(lVel);
lVel *= Vector3.Magnitude(particle.velocity);

pVel = pe.transform.TransformDirection(lVel)
+ Krakensbane.GetFrameVelocity();
Expand Down

0 comments on commit 36e76fd

Please sign in to comment.