MousePick.java: Remove non-effective if clause (2 posts)

  • Profile picture of jamesaguilar jamesaguilar said 1 year, 9 months ago:

    results.getNumber() is already tested in the for loop. Probably not worth giving me commit privileges for this, so if someone would just apply the change for me . . .

    Also, I may be completely out of my mind, but does this class basically do nothing right now? I can't find any outputs unless someone is parsing text later.

    Index: src/jmetest/intersection/MousePick.java
    ===================================================================
    — src/jmetest/intersection/MousePick.java (revision 5674)
    +++ src/jmetest/intersection/MousePick.java (working copy)
    @@ -43,6 +43,8 @@
    import com.jme.scene.Text;

    /**
    + * When the mouse button is pressed, casts a ray in the from the camera along its look vector, and logs struck objects
    + * to the text constructor parameter.
      * <code>MousePick</code>
      * @author Mark Powell
      * @version
    @@ -77,14 +79,14 @@

                hits += results.getNumber();
                hitItems = "";
    -            if(results.getNumber() > 0) {
    -                for(int i = 0; i < results.getNumber(); i++) {
    -                    hitItems += results.getPickData(i).getTargetMesh().getName() + " " + results.getPickData(i).getDistance();
    -                    if(i != results.getNumber() -1) {
    -                        hitItems += ", ";
    -                    }
    +
    +            for(int i = 0; i < results.getNumber(); i++) {
    +                hitItems += results.getPickData(i).getTargetMesh().getName() + " " + results.getPickData(i).getDistance();
    +                if(i != results.getNumber() – 1) {
    +                    hitItems += ", ";
                    }
                }
    +
                shots++;
                results.clear();
                text.print("Hits: " + hits + " Shots: " + shots + " : " + hitItems);

  • Profile picture of jamesaguilar jamesaguilar said 1 year, 9 months ago:

    Edit: I see, it's just for testing, and presumably the text is just parsed by the test to make sure the right things were hit. My bad. Anyhow, the code will still be a minor improvement.