Changeset 268 for trunk/VUT


Ignore:
Timestamp:
09/14/05 18:32:40 (19 years ago)
Author:
mattausch
Message:

did bsp stuff

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r267 r268  
    6565#       splitPlaneStrategy leastSplits 
    6666#       splitPlaneStrategy balancedTree 
    67 #       splitPlaneStrategy nextPolygon 
    68         splitPlaneStrategy combined 
     67        splitPlaneStrategy nextPolygon 
     68#       splitPlaneStrategy combined 
    6969#       constructionMethod rays 
    7070        constructionMethod viewCells 
    7171#       constructionMethod sceneGeometry 
    7272        maxCandidates 25 
    73         maxViewCells 9999 
     73        maxViewCells 999999 
    7474        Termination { 
    7575                maxPolygons 0 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r260 r268  
    11841184          optInt, 
    11851185          "-bsp_max_viewcells=", 
    1186           "9999"); 
     1186          "999999"); 
    11871187} 
    11881188 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Plane3.h

    r265 r268  
    5050                if (coplanar)  
    5151                        (*coplanar) = true;      
    52          
     52                Debug << "signum is zero" << endl; 
    5353                return a; 
    5454        } 
     
    6262      (*t) = u; 
    6363     
    64     return a + u * b - u * a; // NOTE: gives better precision than calclulating a + u * v 
     64    return a - Distance(a) * b / dv + Distance(a) * a / dv; // NOTE: gives better precision than calclulating a + u * v 
    6565    //return a + (u * v); 
    6666  } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r265 r268  
    11#include "Polygon3.h" 
    22#include "Mesh.h" 
    3  
     3#include "ViewCellBsp.h" // TODO: erase this 
     4// tolerance value for side relation 
    45#define SIDE_TOLERANCE 0.002f // TODO: Test different values 
    56 
     
    114115        { 
    115116                int side = plane.Side(*it, SIDE_TOLERANCE); 
    116                 //Debug << "side: " << side << " " << plane.Distance(*it) << endl; 
     117                if (BspTree::displayDebug) Debug << "side: " << side << " " << plane.Distance(*it) << endl; 
    117118 
    118119                if (side > 0) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r265 r268  
    4848                @param objects the intersectables the viewcells are derived from 
    4949                @param viewCells the viewcells are returned in this container 
    50                 @param maxViewCells if > 0, indicates the maximim number of viewcells that will be created 
     50                @param maxViewCells the maximum number of viewcells created. if 0 => unbounded 
    5151        */ 
    5252        static void DeriveViewCells(const ObjectContainer &objects,  
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r267 r268  
    3333const int FACTOR_LEAST_SPLITS = 1; 
    3434 
     35int counter = 0; 
     36bool BspTree::displayDebug = false; 
    3537/****************************************************************/ 
    3638/*                  class BspNode implementation                */ 
    3739/****************************************************************/ 
    3840 
    39 BspNode::BspNode(): mParent(NULL), mPolygons(NULL) 
     41BspNode::BspNode(): mParent(NULL), mPolygons(NULL),mViewCellIdx(0) 
    4042{} 
    4143 
    42 BspNode::BspNode(BspInterior *parent): mParent(parent), mPolygons(NULL) 
     44BspNode::BspNode(BspInterior *parent): mParent(parent), mPolygons(NULL),mViewCellIdx(0) 
    4345{} 
    4446 
     
    147149                                                                int &splits, bool storePolys) 
    148150{ 
    149 #ifdef _Debug 
     151//#ifdef _Debug 
     152        if (BspTree::displayDebug) 
    150153        Debug << "Splitting polygons of node " << this << " with plane " << mPlane << endl; 
    151 #endif 
     154//#endif 
    152155        bool inside = false; 
    153156 
     
    157160                polys->pop_back(); 
    158161 
     162                if (BspTree::displayDebug) Debug << "New polygon with plane: " << poly->GetSupportingPlane() << "\n"; 
     163 
    159164                // test if split is neccessary 
    160165                int classification = poly->ClassifyPlane(mPlane); 
     
    162167                Polygon3 *front_piece = NULL; 
    163168                Polygon3 *back_piece = NULL; 
    164                  
     169         
    165170                switch (classification) 
    166171                { 
     
    170175                                        // same surface normal 
    171176                                        inside = (DotProd(mPlane.mNormal, poly->GetSupportingPlane().mNormal) > 0); 
    172                                          
    173                                 //Debug << "coincident" << endl; 
     177                                        if (BspTree::displayDebug)       
     178                                Debug << "coincident" << endl; 
    174179                                // discard polygons or saves them in node 
    175180                                ProcessPolygon(poly, storePolys); 
    176181                                break; 
    177                         case Polygon3::FRONT_SIDE: 
    178                                 //Debug << "front" << endl; 
     182                        case Polygon3::FRONT_SIDE:      if (BspTree::displayDebug) 
     183                                Debug << "front" << endl; 
    179184                                frontPolys->push_back(poly); 
    180185                                break; 
    181186                        case Polygon3::BACK_SIDE: 
    182                                 inside = true; 
    183                                 //Debug << "back" << endl; 
     187                                inside = true;  if (BspTree::displayDebug) 
     188                                Debug << "back" << endl; 
    184189                                backPolys->push_back(poly); 
    185190                                break; 
    186191                        case Polygon3::SPLIT: 
    187                                 inside = true; 
    188                                 //Debug << "split " << poly << endl; 
     192                                inside = true;                           
    189193 
    190194                                front_piece = new Polygon3(); 
     
    197201                                backPolys->push_back(back_piece); 
    198202 
    199 #ifdef _DEBUG 
    200                                 Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl; 
    201 #endif 
     203//#ifdef _DEBUG 
     204                                if (BspTree::displayDebug)Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl; 
     205//#endif 
    202206                                // save or discard polygons 
    203207                                ProcessPolygon(poly, storePolys); 
     
    258262mRoot(NULL),  
    259263mIsIncremential(false), 
    260 mStorePolys(false) 
     264mStorePolys(true) 
    261265{ 
    262266        Randomize(); // initialise random generator for heuristics 
     
    440444                Polygon3 *poly = new Polygon3((*fi), mesh); 
    441445                polys.push_back(poly); 
     446                if (displayDebug) 
     447                        Debug << *poly << endl; 
    442448                polysNum ++; 
    443449        } 
     
    531537 
    532538        long startTime = GetTime(); 
    533  
    534         int counter = 0; 
     539displayDebug = true; 
     540        counter = 0; 
    535541        Debug << "**** Starting view cell insertion ****" << endl; 
    536542        for (it = viewCells.begin(); it != viewCells.end(); ++ it) 
    537543        { 
    538                 Debug << "** inserting view cell " << counter ++ << " **" << endl; 
    539                 InsertViewCell(*it); 
     544                if ((counter == 12) || (counter == 14)) 
     545                {Debug << "** inserting view cell " << counter << " **" << endl; 
     546                InsertViewCell(*it);} 
     547                counter ++; 
    540548        } 
    541549 
     
    609617        { 
    610618//#ifdef _DEBUG 
    611                 Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " << (int)tData.mPolygons->size() << endl; 
     619                if (displayDebug) 
     620                        Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " << (int)tData.mPolygons->size() << endl; 
    612621//#endif 
    613622 
     
    620629 
    621630                        if (leaf->GetViewCell()) 
    622                                 Debug << "ERROR: leaf already has view cell" << endl; 
    623  
     631                                Debug << "ERROR: leaf already has view cell " << leaf->mViewCellIdx << endl; 
     632 
     633                        leaf->mViewCellIdx = counter; 
    624634                        Debug << "insert view cell" << endl; 
    625635                        leaf->SetViewCell(viewCell); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r267 r268  
    144144        */ 
    145145        PolygonContainer *GetPolygons(); 
    146  
     146int mViewCellIdx; 
    147147protected: 
    148148 
     
    193193                return s << A.mPlane; 
    194194        } 
    195  
    196195 
    197196protected: 
     
    318317        bool Export(const string filename); 
    319318 
    320  
     319static bool displayDebug; 
    321320protected: 
    322321         
Note: See TracChangeset for help on using the changeset viewer.