Possible leak in BoundingSphere.collideWithRay

Hey,

while browsing trought the collisioncode i noticed that in some cases the TempVars are not released. It’s still early in the morning here but it doen’t look correctly.

[java]
public boolean intersects(Ray ray) {
assert Vector3f.isValidVector(center);

    TempVars vars = TempVars.get();

    Vector3f diff = vars.vect1.set(ray.getOrigin()).subtractLocal(center);
    float radiusSquared = getRadius() * getRadius();
    float a = diff.dot(diff) - radiusSquared;
    if (a <= 0.0) {
        // in sphere
        return true;
    }

    // outside sphere
    float b = ray.getDirection().dot(diff);
    vars.release();
    if (b >= 0.0) {
        return false;
    }
    return b * b >= a;
}

[/java]

Inside the ‘In Sphere’ branch a ‘vars.release()’ should be called before returing true.

Sorry, i currently don’t have the jme sources here so i can’t provide a patch

1 Like

Add: It’s in the BoundingSphere.java line 719,

Oh nice catch!
I’ll fix this asap

that’s fixed

2 Likes