MinieLibrary/src/main/java/com/jme3/bullet/animation/RagUtils.java
/**
     * Traverse a group of bodies joined by physics joints, adding bodies to the
     * ignore list of the start body. Note: recursive!
     *
     * @param start the body where the traversal began (not null, unaffected)
     * @param current the body to traverse (not null, unaffected)
     * @param hopsRemaining the number of hops remaining (&ge;0)
     * @param visited map bodies visited during the current traversal to max
     * remaining hops (not null, modified)
     */
Traverse a group of bodies joined by physics joints, adding bodies to the
ignore list of the start body. Note: recursive!

@param start the body where the traversal began (not null, unaffected)
@param current the body to traverse (not null, unaffected)
@param hopsRemaining the number of hops remaining (≥0)
@param visited map bodies visited during the current traversal to max
remaining hops (not null, modified)
Traverse a group of bodies joined by physics joints adding bodies to the ignore list of the start body . Note : recursive! @param start the body where the traversal began ( not null unaffected ) @param current the body to traverse ( not null unaffected ) @param hopsRemaining the number of hops remaining ( ≥0 ) @param visited map bodies visited during the current traversal to max remaining hops ( not null modified )
static void ignoreCollisions(PhysicsBody start, PhysicsBody current,
            int hopsRemaining, Map<PhysicsBody, Integer> visited) {
        if (hopsRemaining <= 0) {
            return;
        }
        int newRemainingHops = hopsRemaining - 1;
        /*
         * Consider each neighboring body that isn't the starting body.
         */
        PhysicsJoint[] joints = current.listJoints();
        for (PhysicsJoint joint : joints) {
            PhysicsBody neighbor = joint.findOtherBody(current);
            if (neighbor != null && neighbor != start) {
                /*
                 * Decide whether or not to visit (or re-visit) the neighbor.
                 */
                boolean visit = true;
                if (visited.containsKey(neighbor)) { 
                    int mostRemainingHops = visited.get(neighbor);
                    if (newRemainingHops <= mostRemainingHops) {
                        visit = false;
                    }
                }
                if (visit) {
                    start.addToIgnoreList(neighbor);
                    visited.put(neighbor, newRemainingHops);
                    ignoreCollisions(start, neighbor, newRemainingHops,
                            visited);
                }
            }
        }
    }
static void ignoreCollisions ( PhysicsBody start , PhysicsBody current , int hopsRemaining , Map < PhysicsBody , Integer > visited ) { if ( hopsRemaining <= 0 ) { return ; } int newRemainingHops = hopsRemaining - 1 ; /*
         * Consider each neighboring body that isn't the starting body.
         */ PhysicsJoint [ ] joints = current . listJoints ( ) ; for ( PhysicsJoint joint : joints ) { PhysicsBody neighbor = joint . findOtherBody ( current ) ; if ( neighbor != null && neighbor != start ) { /*
                 * Decide whether or not to visit (or re-visit) the neighbor.
                 */ boolean visit = true ; if ( visited . containsKey ( neighbor ) ) { int mostRemainingHops = visited . get ( neighbor ) ; if ( newRemainingHops <= mostRemainingHops ) { visit = false ; } } if ( visit ) { start . addToIgnoreList ( neighbor ) ; visited . put ( neighbor , newRemainingHops ) ; ignoreCollisions ( start , neighbor , newRemainingHops , visited ) ; } } } }
Traverse a group of bodies joined by physics joints, adding bodies to the
 ignore list of the start body.
Traverse a group of bodies joined by physics joints adding bodies to the ignore list of the start body .
// previously visited
 // don't revisit
