Ignore:
Timestamp:
09/11/06 00:29:47 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp

    r1076 r1328  
    316316int Polygon3::CastRay(const Ray &ray, float &t, const float nearestT) 
    317317{ 
    318         Plane3 plane = GetSupportingPlane(); 
    319         float dot = DotProd(plane.mNormal, ray.GetDir()); 
     318        const Plane3 plane = GetSupportingPlane(); 
     319        const float dot = DotProd(plane.mNormal, ray.GetDir()); 
    320320 
    321321        // Watch for near-zero denominator 
    322322        // ONLY single sided polygons!!!!! 
    323323        if (dot > -Limits::Small) 
    324         //  if (fabs(dot) < Limits::Small) 
    325         return Ray::NO_INTERSECTION; 
     324        { 
     325                //  if (fabs(dot) < Limits::Small) 
     326                return Ray::NO_INTERSECTION; 
     327        } 
    326328 
    327329        t = (-plane.mD - DotProd(plane.mNormal, ray.GetLoc())) / dot; 
    328330 
    329331        if (t <= Limits::Small) 
    330         return Ray::INTERSECTION_OUT_OF_LIMITS; 
    331  
    332         if (t >= nearestT) { 
    333         return Ray::INTERSECTION_OUT_OF_LIMITS; // no intersection was found 
     332        { 
     333                return Ray::INTERSECTION_OUT_OF_LIMITS; 
     334        } 
     335 
     336        if (t >= nearestT)  
     337        { 
     338                return Ray::INTERSECTION_OUT_OF_LIMITS; // no intersection was found 
    334339        } 
    335340 
     
    338343        int i; 
    339344 
    340         int paxis = plane.mNormal.DrivingAxis(); 
     345        const int paxis = plane.mNormal.DrivingAxis(); 
    341346 
    342347        // Project the intersection point onto the coordinate plane 
     
    344349        ray.Extrap(t).ExtractVerts(&u, &v, paxis); 
    345350 
    346         int size = (int)mVertices.size(); 
     351        const int size = (int)mVertices.size(); 
    347352 
    348353        mVertices.back().ExtractVerts(&u1, &v1, paxis ); 
     
    354359                { 
    355360                mVertices[i].ExtractVerts(&u2, &v2, paxis); 
    356              
     361            
    357362                        // line u1, v1, u2, v2 
    358              
    359                         if ((v2 - v1)*(u1 - u) > (u2 - u1)*(v1 - v)) 
     363                        if ((v2 - v1) * (u1 - u) > (u2 - u1)*(v1 - v)) 
    360364                                return Ray::NO_INTERSECTION; 
    361365 
    362366                        u1 = u2; 
    363367                        v1 = v2; 
    364         } 
    365  
    366         return Ray::INTERSECTION; 
     368                } 
     369                 
     370                return Ray::INTERSECTION; 
    367371        } 
    368372 
     
    537541 
    538542                if ((count ++) % 2) 
     543                { 
    539544                        j = i ++; 
     545                } 
    540546                else 
     547                { 
    541548                        j = k --; 
     549                } 
    542550        } 
    543551} 
     
    575583} 
    576584 
    577 } 
     585 
     586AxisAlignedBox3 Polygon3::GetBoundingBox() const 
     587{ 
     588        VertexContainer::const_iterator vit, vit_end = mVertices.end(); 
     589         
     590        AxisAlignedBox3 box; 
     591        box.Initialize(); 
     592 
     593        for (vit = mVertices.begin(); vit != vit_end; ++ vit) 
     594        { 
     595                box.Include(*vit); 
     596        } 
     597 
     598        return box; 
     599} 
     600 
     601 
     602} 
Note: See TracChangeset for help on using the changeset viewer.