Exemplo n.º 1
0
        public void apply()
        {
            if (on)
            {
                //float deltaAngle = GetDeltaAngle();

                if (delta == 0f || Mathf.Abs(delta) < 0.01f)
                {
                    return;
                }
                else
                {
                    Vector2 posB = particleB.Position;
                    Vector2 posM = particleM.Position;
                    if (particleB.IsFree)
                    {
                        particleB.Position = Mathp.RotateVector2(posB, posM, -delta * sim.Settings.angleConstant);
                    }
                    if (particleM.IsFree)
                    {
                        particleM.Position = Mathp.RotateVector2(posM, posB, -delta * sim.Settings.angleConstant);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void applyThreaded()
 {
     if (on)
     {
         Vector2 posA, posB, posM;
         //lock(particleA) lock(particleB) lock(particleM) {
         posA      = particleA.Position;
         posB      = particleB.Position;
         posM      = particleM.Position;
         angle_Cur = GetAngleRadian(posA, posM, posB);
         //}
         float deltaAngle = GetDeltaAngle();
         if (deltaAngle == 0f || Mathf.Abs(deltaAngle) < 0.01f)
         {
             return;
         }
         else
         {
             if (particleA.IsFree)
             {
                 //lock (particleA) {
                 Vector2 posA2 = Mathp.RotateVector2(posA, posM, deltaAngle * sim.Settings.angleConstant);
                 posA2 = posA2 - posA;
                 Extension.InterlockAddFloat(ref particleA.Position.x, posA2.x);
                 Extension.InterlockAddFloat(ref particleA.Position.y, posA2.y);
                 //}
             }
             if (particleB.IsFree)
             {
                 //lock(particleB) {
                 Vector2 posB2 = Mathp.RotateVector2(posB, posM, -deltaAngle * sim.Settings.angleConstant);
                 posB2 -= posB;
                 Extension.InterlockAddFloat(ref particleB.Position.x, posB2.x);
                 Extension.InterlockAddFloat(ref particleB.Position.y, posB2.y);
                 //}
             }
             if (particleM.IsFree)
             {
                 //lock (particleM) {
                 Vector2 posM2 = Mathp.RotateVector2(posM, posA, deltaAngle * sim.Settings.angleConstant);
                 posM2  = Mathp.RotateVector2(posM2, posB, -deltaAngle * sim.Settings.angleConstant);
                 posM2 -= posM;
                 Extension.InterlockAddFloat(ref particleM.Position.x, posM2.x);
                 Extension.InterlockAddFloat(ref particleM.Position.y, posM2.y);
                 //}
             }
         }
     }
 }