Export to GitHub

monoxna - issue #85

BoundingFrustum.Contains(BoundingSphere)


Posted on Jan 24, 2013 by Massive Giraffe

BoundingFrustum.Contains(BoundingSphere)

The method is incomplete, one solution could be:

// changing this method float PlaneHelper::PerpendicularDistance(Vector3 point, Plane plane) { float result = plane.D+ Vector3::Dot(plane.Normal,point); return -result; }

ContainmentType::ContainmentType BoundingFrustum::Contains(BoundingSphere sphere)
{
    float val;
    ContainmentType::ContainmentType result = ContainmentType::Contains;

    vector<Plane> planes = GetPlanes();  // array of Planes 
    for(int i=0 ; i < planes.size(); ++i){
        val = PlaneHelper::PerpendicularDistance(sphere.Center, planes[i]);
        if (val < -sphere.Radius)
            return ContainmentType::Disjoint;
        else if (val < sphere.Radius)
            result = ContainmentType::Intersects;
    }
    return result;
}

sorry, it's in C++

more info, here: http://zach.in.tu-clausthal.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/index.html

Status: New