thargor6 / JWildfire

JWildfire - powerful, flexible and user-friendly fractal flame editor
http://www.andreas-maschke.com
206 stars 55 forks source link

variation PRose3DFunc: Method uses the same code for two branches #42

Closed smack42 closed 8 years ago

smack42 commented 8 years ago

Detected by FindBugs in class JWildfire/src/org/jwildfire/create/tina/variation/PRose3DFunc. The fix would be trivial, just remove the redundant code.

However, I think this can be a real error and that the if/else paths should have contained different code. Please verify.

    else // this is the option when optDir > 0.0
    {
      if (posNeg < 0)
      {
        pVarTP.x += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * cth;
        pVarTP.y += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * sth;
        pVarTP.z += pAmount * 0.5 * ((scaleZ1 * waggle + sqr(rad * 0.5) * sin(wig) * wigScale) + (this.dist));

      }
      else
      {
        pVarTP.x += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * cth;
        pVarTP.y += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * sth;
        pVarTP.z += pAmount * 0.5 * ((scaleZ1 * waggle + sqr(rad * 0.5) * sin(wig) * wigScale) + (this.dist));
      }
    }
  }
thargor6 commented 8 years ago

Interesting, but I did not create this variation, so I'm not sure what was intended. I think, it is better to remove it

smack42 commented 8 years ago

Agreed, lets remove it. The original C-code contains the same code duplication. http://aporev.deviantart.com/gallery/#/d2blmhg