Ignore:
Timestamp:
01/25/06 01:44:46 (18 years ago)
Author:
mattausch
Message:

finished function for view cell construction
removed bsp rays from vspbspmanager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r544 r574  
    77Polygon3::Polygon3():  
    88mMaterial(NULL), mParent(NULL), mPiercingRays(0) 
    9 {} 
     9{ 
     10        // mostly there will be triangles 
     11        //mVertices.reserve(3); 
     12} 
    1013 
    1114Polygon3::Polygon3(const VertexContainer &vertices):  
    12 mVertices(vertices), mMaterial(NULL), mParent(NULL), mPiercingRays(0) 
    13 {} 
     15mMaterial(NULL), mParent(NULL), mPiercingRays(0) 
     16{ 
     17        mVertices.reserve(vertices.size()); 
     18        mVertices = vertices; 
     19} 
     20 
    1421 
    1522Polygon3::Polygon3(MeshInstance *parent):  
     
    1724{} 
    1825 
     26 
    1927Polygon3::Polygon3(Face *face, Mesh *parentMesh): 
    2028mMaterial(NULL), mParent(NULL), mPiercingRays(0) 
    2129{        
     30        mVertices.reserve(face->mVertexIndices.size()); 
     31         
    2232        VertexIndexContainer::iterator it = face->mVertexIndices.begin(); 
    2333        for (; it != face->mVertexIndices.end();  ++it) 
    2434        { 
    2535                mVertices.push_back(parentMesh->mVertices[*it]); 
    26                 mMaterial = parentMesh->mMaterial; 
    27         } 
    28 } 
     36        } 
     37 
     38        mMaterial = parentMesh->mMaterial; 
     39} 
     40 
    2941 
    3042Plane3 Polygon3::GetSupportingPlane() const 
     
    3244        return Plane3(mVertices[0], mVertices[1], mVertices[2]); 
    3345} 
     46 
    3447 
    3548Vector3 Polygon3::GetNormal() const  
     
    113126} 
    114127 
     128 
    115129float Polygon3::GetArea() const 
    116130{ 
     
    123137} 
    124138 
     139 
    125140int Polygon3::Side(const Plane3 &plane,  
    126141                                   const float epsilon) const 
     
    136151} 
    137152 
     153 
    138154int Polygon3::ClassifyPlane(const Plane3 &plane,  
    139155                                                        const float epsilon) const 
    140156{ 
    141         VertexContainer::const_iterator it; 
     157        VertexContainer::const_iterator it, it_end = mVertices.end(); 
    142158 
    143159        bool onFrontSide = false; 
     
    146162        int count = 0; 
    147163        // find possible line-plane intersections 
    148         for (it = mVertices.begin(); it != mVertices.end(); ++ it) 
     164        for (it = mVertices.begin(); it != it_end; ++ it) 
    149165        { 
    150166                const int side = plane.Side(*it, epsilon); 
     
    179195} 
    180196 
    181 /*int Polygon3::ClassifyPlane(const Plane3 &plane) const 
    182 { 
    183         return ClassifyPlane(plane, Limits::Small); 
    184 }*/ 
    185  
    186197 
    187198Vector3 
     
    212223                return false; 
    213224 
    214 #if 1 
    215         // check if area exceeds certain size 
    216         if (AREA_LIMIT > GetArea()) 
    217         { 
    218                 //Debug << "area too small: " << GetArea() << endl; 
    219                 return false; 
    220         } 
    221 #else 
    222         Vector3 vtx = mVertices.back(); 
    223         VertexContainer::const_iterator it, it_end = mVertices.end(); 
    224  
    225         for (it = mVertices.begin(); it != it_end; ++it) 
    226         { 
    227                 if (!(EpsilonEqual(vtx, *it))) 
    228                 { 
    229                         //Debug << "Malformed vertices:\n" << *this << endl; 
     225        //TODO: remove for performance 
     226#if 0 
     227        if (1) 
     228        { 
     229                // check if area exceeds certain size 
     230                if (GetArea() < AREA_LIMIT) 
     231                { 
     232                        Debug << "area too small: " << GetArea() << endl; 
    230233                        return false; 
    231234                } 
    232                 vtx = *it; 
    233         } 
    234 #endif   
     235        } 
     236        else 
     237        { 
     238                Vector3 vtx = mVertices.back(); 
     239                VertexContainer::const_iterator it, it_end = mVertices.end(); 
     240 
     241                for (it = mVertices.begin(); it != it_end; ++it) 
     242                { 
     243                        if (!(EpsilonEqualV3(vtx, *it))) 
     244                        { 
     245                                //Debug << "Malformed vertices:\n" << *this << endl; 
     246                                return false; 
     247                        } 
     248                        vtx = *it; 
     249                } 
     250        } 
     251#endif 
     252 
    235253        return true; 
    236254} 
     255 
    237256 
    238257void Polygon3::IncludeInBox(const PolygonContainer &polys, AxisAlignedBox3 &box) 
     
    243262                box.Include(*(*it)); 
    244263} 
     264 
    245265 
    246266// int_lineseg returns 1 if the given line segment intersects a 2D 
     
    283303} 
    284304 
     305 
    285306int Polygon3::CastRay(const Ray &ray, float &t, const float nearestT) 
    286307{ 
     
    353374        return (count & 1) ? Ray::INTERSECTION : Ray::NO_INTERSECTION; 
    354375} 
     376 
    355377 
    356378void Polygon3::InheritRays(Polygon3 &front_piece,  
     
    385407} 
    386408 
     409 
    387410int Polygon3::ClassifyPlane(const PolygonContainer &polys,  
    388411                                                        const Plane3 &plane, 
     
    422445} 
    423446 
     447 
    424448int Polygon3::ParentObjectsSize(const PolygonContainer &polys) 
    425449{ 
     
    441465} 
    442466 
     467 
    443468float Polygon3::GetArea(const PolygonContainer &cell) 
    444469{ 
     
    448473        for (pit = cell.begin(); pit != cell.end(); ++ pit) 
    449474        { 
    450                 if ((*pit)->mVertices.size() < 3) 
    451                         Debug << "ERROR" << endl; 
    452  
    453475                area += (*pit)->GetArea(); 
    454476        } 
Note: See TracChangeset for help on using the changeset viewer.