Fix in BoundingSphere.merge()

Hi:



I'm new here, so please bear with me if the format of my fix proposal is incorrect or incomplete.



I found a defect in the merge() method of BoundingSphere and have identified a fix.

Here's a code snippet:


private BoundingVolume merge(float temp_radius, Vector3f temp_center, BoundingSphere rVal) {
...
...
        Vector3f rCenter = rVal.getCenter();
        if ( rCenter == null ) {
            rVal.setCenter( rCenter = new Vector3f() );
        }
    -   if (length > radiusEpsilon) {
    +  if ((length + temp_radius) > radius) {
            float coeff = (length + radiusDiff) / (2.0f * length);
            rCenter.set(center.addLocal(diff.multLocal(coeff)));
        } else {
            rCenter.set(center);
        }

        rVal.setRadius(0.5f * (length + radius + temp_radius));
        return rVal;
    }


The if test [at line 607] in BoundingSphere.merge() was causing the Bounding Sphere center to not move if the distance between the two sphere's being merged was less than radiusEpsilon.
The corrected test now looks for the case where the sum of the center-center distance and the second sphere radius is greater than the radius of 'this'.


I have tested the fix in my software [which as it happens, is not a game] and verified that the merge method now operates correctly.

I surely do not have commit access, so perhaps Momoko_Fan or normen can perform that step if you are satisfied with the fix.


All the best.

cheers
-jg-