mjs513 / monoxna

Automatically exported from code.google.com/p/monoxna
Other
0 stars 0 forks source link

BoundingFrustum.Contains(BoundingSphere) #85

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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_c
ulling/index.html

Original issue reported on code.google.com by hdlopesr...@gmail.com on 24 Jan 2013 at 11:35