Ignore:
Timestamp:
01/31/07 01:51:57 (17 years ago)
Author:
mattausch
Message:

worked on integration manual

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
69 added
23 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env

    r2065 r2066  
    55 
    66Scene { 
    7 #       filename ../data/vienna/vienna_cropped.obj 
    8         filename ../data/soda/soda5.obj 
     7        filename ../data/vienna/vienna_cropped.obj 
     8#       filename ../data/soda/soda5.obj 
     9#       filename ../data/soda/soda5.dat 
    910} 
    1011 
     
    8687                maxDepth 20 
    8788                 
    88                 maxCostRatio 2.5 
     89                maxCostRatio 1.5 
     90                #maxCostRatio 999999 
    8991                ct_div_ci 0.5 
    9092        } 
     
    127129 
    128130        exportPvs false 
     131        filename vienna_cropped-visibility.xml.gz 
    129132 
    130133        # type of view cells 
     
    164167        } 
    165168 
    166         showVisualization true 
    167         #showVisualization false 
     169        #showVisualization true 
     170        showVisualization false 
    168171        evaluateViewCells false 
    169172         
     
    187190VspBspTree { 
    188191        Construction { 
    189                 samples 300000 
     192                samples 2000000 
    190193                epsilon 0.0000001 
    191194                randomize false 
     
    208211 
    209212        # maximal tested rays for split cost heuristics 
    210         maxTests 10000 
     213        maxTests 100000 
    211214         
    212215        maxTotalMemory  50 
     
    235238                minGlobalCostRatio      0.0001 
    236239 
    237                 maxViewCells            200 
    238          
    239  
     240                maxViewCells            5000 
     241         
    240242                # used for pvs criterium 
    241243                ct_div_ci 0.0 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.sh

    r2064 r2066  
    99PROGRAM=../bin/$TARGET/Preprocessor.exe 
    1010 
    11 #SCENE=vienna_cropped 
    12 SCENE=soda5 
     11SCENE=vienna_cropped 
     12#SCENE=soda5 
    1313 
    1414LOG_PREFIX=../scripts/$SCENE 
     
    3333 
    3434$PROGRAM $ENVIRONMENT \ 
    35 -view_cells_type=vspBspTree \ 
    3635-view_cells_filename=$LOG_PREFIX-visibility.xml.zip 
    3736 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BoundingBoxConverter.h

    r1676 r2066  
    1616}; 
    1717 
    18 /** Class used to assign unique indices to objects using a comparison of bounding boxes. 
     18/** Class used to assign unique indices to objects using a  
     19        comparison of bounding boxes. 
    1920*/ 
    2021class BoundingBoxConverter 
    2122{ 
    2223public: 
    23         /** Takes a vector of indexed bounding boxes and uses it to identify objects with a similar bounding box 
    24                 and assigns them their index (id). 
     24        /** Takes a vector of indexed bounding boxes and uses it to  
     25                identify objects with a similar bounding box 
     26                and assigns them the proper index (id). 
    2527                The objects are returned in the object container. 
    2628                 
     
    3032                                                                 ObjectContainer &objects) const 
    3133        { 
    32                 // default: do nothing as we assume that a unique id is already assigned to the objects. 
     34                // default: do nothing as we assume that a unique id is  
     35                // already assigned to the objects. 
    3336                return true; 
    3437        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/CombinedPreprocessor.cpp

    r2051 r2066  
    119119         
    120120        if (i - lastEvaluation >= mSamplesPerEvaluation) { 
    121           long time = TimeDiff(startTime, GetTime()); 
     121          Real time = TimeDiff(startTime, GetTime()); 
    122122          mViewCellsManager->PrintPvsStatistics(mStats); 
    123123          mStats << 
     
    147147         
    148148         
    149         long time = TimeDiff(startTime, GetTime()); 
     149        Real time = TimeDiff(startTime, GetTime()); 
    150150        if (mTotalTime!= -1 && time/1000 > mTotalTime) 
    151151          break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r2017 r2066  
    19511951                if (!vc->GetPvs().Empty()) 
    19521952                { 
    1953                         //if (vc->IsLeaf()) cout << " l " << pvs.GetSize(); 
    1954                         //else cout << " i " << pvs.GetSize(); 
    19551953                        pvs.MergeInPlace(vc->GetPvs()); 
    19561954                } 
    19571955                else if (!vc->IsLeaf()) // interior cells: go down to leaf level 
    19581956                { 
    1959                         //cout <<" t"; 
    19601957                        ViewCellInterior *interior = static_cast<ViewCellInterior *>(vc); 
    19611958                        ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     
    19661963                        }                
    19671964                } 
    1968                 else cout <<"k"; 
    19691965        } 
    19701966} 
     
    21042100                        //GetPvsRecursive(vc, pvs); 
    21052101                        vc->SetPvs(pvs); 
    2106                         //cout << "q"; 
    2107                 } 
    2108                 //else cout << "t"; 
     2102                } 
    21092103#endif 
    21102104 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r2048 r2066  
    1818 
    1919 
    20 struct FaceParentInfo { 
     20struct FaceParentInfo  
     21{ 
    2122        /// intersectable 
    2223        Intersectable *mObject; 
     
    3031 
    3132 
    32 class Intersectable { 
     33class Intersectable  
     34{ 
    3335public: 
    3436  
     
    4244  BvhLeaf *mBvhLeaf; 
    4345   
    44   /// # of references to this instance 
    45   //int mReferences; 
    46  
    47   ////////////////// 
    48   // note matt: delete these, they are only taking memory 
    49  
    50   /// object based pvs 
    51   //KdPvs mKdPvs; 
    52  
    53   /// view cell based pvs per object 
    54   //ViewCellPvs mViewCellPvs; 
    55          
    5646  /////////////////////// 
    5747 
     
    6454                 BVH_INTERSECTABLE, 
    6555                 TRIANGLE_INTERSECTABLE, 
    66                  OBJECTS_INTERSECTABLE, 
    67                  DUMMY_INTERSECTABLE 
     56                 DUMMY_INTERSECTABLE, 
     57                 ENGINE_INTERSECTABLE, 
    6858                }; 
    6959   
    70   Intersectable():  
    71         mMailbox(0),  
    72   //mReferences(0),  
    73   mBvhLeaf(0),  
    74   mVssRays(NULL) {} 
     60  Intersectable(); 
    7561 
    76   virtual Intersectable::~Intersectable() {DEL_PTR(mVssRays);} 
     62  virtual ~Intersectable(); 
    7763 
    7864  void SetId(const int id) { mId = id; } 
    7965  int GetId() { return mId; } 
    8066   
    81   //////////////////////////////////////////////// 
    82   //    Mailing stuff 
     67  ///////////// 
     68  // Mailing stuff 
    8369   
    84   static void NewMail(const int reserve = 1) { 
    85         sMailId += sReservedMailboxes; 
    86         sReservedMailboxes = reserve; 
     70  static void NewMail(const int reserve = 1)  
     71  { 
     72          sMailId += sReservedMailboxes; 
     73          sReservedMailboxes = reserve; 
    8774  } 
    8875         
     
    10491   
    10592 
    106   //////////////////////////////////////////////////// 
     93  //////////////// 
     94  // virtual interface 
     95 
    10796  virtual AxisAlignedBox3 GetBox() const = 0; 
    10897  virtual int CastRay(Ray &ray) = 0; 
     
    114103  virtual int NumberOfFaces() const = 0; 
    115104  virtual int Type() const = 0; 
    116   virtual float GetArea() const {return 0; } 
     105   
    117106  virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0; 
    118   virtual int GetRandomSurfacePoint(const float u, 
    119                                                                         const float v, 
    120                                                                         Vector3 &point, 
    121                                                                         Vector3 &normal) { 
    122         cerr<<"GetRandomSurfacePoint(u,v...) not yet implemented"<<endl; 
    123         return 1; 
    124   } 
    125  
     107  
    126108  virtual int GetRandomEdgePoint(Vector3 &point, 
    127109                                                                 Vector3 &normal) = 0; 
     
    132114                                           const int maxTries) = 0; 
    133115 
    134  // virtual int GetRandomPoint(Vector3 &point, 
    135 //                                                       Vector3 &normal) = 0; 
     116  // virtual int GetRandomPoint(Vector3 &point, 
     117  // vector3 &normal) = 0; 
    136118 
    137119  virtual ostream &Describe(ostream &s) = 0; 
    138120 
     121  ////////////////////////////////////// 
     122 
     123 
    139124  virtual int GenerateSilhouetteRays(const int nrays, 
    140           const AxisAlignedBox3 &originBox, 
    141           const AxisAlignedBox3 &directionBox, VssRayContainer &rays)  
    142   { 
    143           return 0; 
    144   } 
     125                                                                         const AxisAlignedBox3 &originBox, 
     126                                                                         const AxisAlignedBox3 &directionBox,  
     127                                                                         VssRayContainer &rays);  
     128   
     129   virtual int GetRandomSurfacePoint(const float u, 
     130                                                                         const float v, 
     131                                                                         Vector3 &point, 
     132                                                                         Vector3 &normal); 
    145133 
    146   static bool GreaterCounter(const Intersectable *a, 
    147           const Intersectable *b)  
    148   { 
    149           return a->mCounter > b->mCounter; 
    150   } 
     134   virtual float GetArea() const; 
    151135 
    152   static string GetTypeName(Intersectable *obj) 
    153   { 
    154           switch(obj->Type()) 
    155           { 
    156           case MESH_INSTANCE: 
    157                   return "mesh_instance\n"; 
     136   static bool GreaterCounter(const Intersectable *a, 
     137                                                          const Intersectable *b); 
    158138 
    159           case TRANSFORMED_MESH_INSTANCE: 
    160                   return "transformed_mesh_instance\n"; 
     139  /** Returns the name of the type of this intersectable 
     140  */ 
     141  static string GetTypeName(Intersectable *obj); 
    161142 
    162           case SPHERE: 
    163                   return "sphere\n"; 
     143   /** Returns normal from the face with the specified index. 
     144   PROBLEM: Does not fit to all intersectable types (e.g., spheres) 
     145   */ 
     146   virtual Vector3 GetNormal(const int idx) const; 
    164147 
    165           case VIEW_CELL: 
    166                   return "view cell\n"; 
     148   /** Returns rays stored with this intersectable. 
     149   */ 
     150   VssRayContainer *GetOrCreateRays(); 
    167151 
    168           case OGRE_MESH_INSTANCE: 
    169                   return "ogre_mesh_instance\n"; 
    170  
    171           case KD_INTERSECTABLE: 
    172                   return "kd_intersectable\n"; 
    173  
    174           default: 
    175                   return "unknown\n"; 
    176           } 
    177   } 
    178  
    179   /** Returns normal from the face with the specified index. 
    180           PROBLEM: Does not fit to all intersectable types (e.g., spheres) 
    181   */ 
    182   virtual Vector3 GetNormal(const int idx) const { return Vector3(0, 0, 0); } 
    183  
    184   VssRayContainer *GetOrCreateRays()  
    185   {  
    186           if (!mVssRays) 
    187                 mVssRays = new VssRayContainer(); 
    188           return mVssRays; 
    189   } 
    190  
    191   void DelRayRefs() 
    192   { 
    193           DEL_PTR(mVssRays); 
    194   } 
     152   /** Deletes the rays associated with this intersectable. 
     153   */ 
     154   void DelRayRefs(); 
    195155 
    196156protected: 
    197157 
    198   /// some rays piercing this intersectable 
    199   VssRayContainer *mVssRays; 
     158        /// some rays piercing this intersectable 
     159        VssRayContainer *mVssRays; 
    200160}; 
    201161 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r2048 r2066  
    165165{ 
    166166public: 
    167   AxisAlignedBox3 mBox; 
    168  
    169   KdIntersectable(KdNode *item, const AxisAlignedBox3 &box); 
    170  
    171    
    172   int Type() const 
    173         { 
    174           return Intersectable::KD_INTERSECTABLE; 
    175         } 
    176  
    177    
    178   AxisAlignedBox3 GetBox() const { 
    179         return mBox; 
    180   } 
     167        AxisAlignedBox3 mBox; 
     168         
     169        KdIntersectable(KdNode *item, const AxisAlignedBox3 &box); 
     170     
     171        int Type() const 
     172        { 
     173                return Intersectable::KD_INTERSECTABLE; 
     174        } 
     175 
     176    AxisAlignedBox3 GetBox() const  
     177        { 
     178                return mBox; 
     179        } 
    181180}; 
    182181 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r2017 r2066  
    1616int KdNode::sMailId = 1; 
    1717int KdNode::sReservedMailboxes = 1; 
     18 
    1819 
    1920inline static bool ilt(Intersectable *obj1, Intersectable *obj2) 
     
    178179 
    179180 
    180  
    181181bool 
    182182KdTree::TerminationCriteriaMet(const KdLeaf *leaf) 
    183183{ 
    184   //  cerr<<"\n OBJECTS="<<leaf->mObjects.size()<<endl; 
    185   return 
    186     ((int)leaf->mObjects.size() <= mTermMinCost) || 
    187     (leaf->mDepth >= mTermMaxDepth); 
    188    
     184        const bool criteriaMet = 
     185                ((int)leaf->mObjects.size() <= mTermMinCost) || 
     186                 (leaf->mDepth >= mTermMaxDepth); 
     187  
     188        if (criteriaMet) 
     189                cerr<<"\n OBJECTS="<<leaf->mObjects.size()<<endl; 
     190 
     191        return criteriaMet; 
    189192} 
    190193 
     
    462465{ 
    463466        CLEAR_CONTAINER(*splitCandidates); 
    464   //splitCandidates->clear(); 
    465    
    466   int requestedSize = 2*(int)node->mObjects.size(); 
    467   // creates a sorted split candidates array 
    468   if (splitCandidates->capacity() > 500000 && 
    469       requestedSize < (int)(splitCandidates->capacity()/10) ) { 
    470     delete splitCandidates; 
    471     splitCandidates = new vector<SortableEntry *>; 
     467        //splitCandidates->clear(); 
     468 
     469    int requestedSize = 2*(int)node->mObjects.size(); 
     470         
     471        // creates a sorted split candidates array 
     472        if (splitCandidates->capacity() > 500000 && 
     473                requestedSize < (int)(splitCandidates->capacity()/10) ) {                
     474                        delete splitCandidates; 
     475                        splitCandidates = new vector<SortableEntry *>; 
    472476  } 
    473477   
     
    477481  for(ObjectContainer::const_iterator mi = node->mObjects.begin(); 
    478482      mi != node->mObjects.end(); 
    479       mi++) { 
    480     AxisAlignedBox3 box = (*mi)->GetBox(); 
    481  
    482     splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MIN, 
    483                                                                                          box.Min(axis), 
    484                                                                                          *mi) 
    485                                                            ); 
     483      mi++)  
     484  { 
     485          AxisAlignedBox3 box = (*mi)->GetBox(); 
     486 
     487          splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MIN, 
     488                                                                 box.Min(axis), 
     489                                                                 *mi) 
     490                                                                 ); 
    486491     
    487      
    488     splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 
    489                                                                                          box.Max(axis), 
    490                                                                                          *mi) 
    491                                                            ); 
    492   } 
    493    
    494   stable_sort(splitCandidates->begin(), splitCandidates->end()); 
     492      splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 
     493                                                                 box.Max(axis), 
     494                                                                 *mi) 
     495                                                                 ); 
     496  } 
     497   
     498  stable_sort(splitCandidates->begin(), splitCandidates->end(), iltS); 
    495499} 
    496500 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r2003 r2066  
    546546     
    547547  }; 
    548    
     548 
     549  inline static bool iltS(SortableEntry *a, SortableEntry *b) 
     550  { 
     551          return a->value < b->value; 
     552  } 
     553 
    549554  // reusable array of split candidates 
    550555  vector<SortableEntry *> *splitCandidates; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2065 r2066  
    13131313        } 
    13141314 
    1315         cout << "here5" << endl; 
    1316  
    13171315        DeterminePvsObjects(vssRays); 
    13181316} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2063 r2066  
    7171                                OptimizeForProcessor="0" 
    7272                                OptimizeForWindowsApplication="TRUE" 
    73                                 AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost" 
     73                                AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 
    7474                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB" 
    7575                                ExceptionHandling="TRUE" 
     
    500500                        </File> 
    501501                        <File 
     502                                RelativePath=".\Intersectable.cpp"> 
     503                        </File> 
     504                        <File 
    502505                                RelativePath=".\Intersectable.h"> 
    503506                        </File> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp

    r2065 r2066  
    144144        KdLeaf::NewMail(); 
    145145 
    146         cout << "here55 " << GetSize() << endl; 
    147  
    148146        ObjectPvsEntries::const_iterator it, it_end = mEntries.end(); 
    149147 
     
    162160                                } 
    163161                        case Intersectable::BVH_INTERSECTABLE: 
    164                                 {cout<< "i"; 
     162                                { 
    165163                                        BvhNode *bvhObj = static_cast<BvhNode *>(obj); 
    166164                                        pvs += EvalBvhNodeContribution(bvhObj); 
     
    168166                                } 
    169167                        default: 
     168                                // hack: should use assigned cost here 
    170169                                ++ pvs; 
     170                                 
    171171                                break; 
    172172                } 
    173173        } 
    174174 
    175         cout << "here44 " << pvs << endl; 
    176175        return pvs; 
    177176} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r2019 r2066  
    140140{ 
    141141public: 
    142 PvsIterator<T, S>(){} 
     142         
     143        PvsIterator<T, S>() {} 
     144 
    143145        PvsIterator<T, S>(const typename vector<PvsEntry<T, S> >::const_iterator &itCurrent, 
    144146                                          const typename vector<PvsEntry<T, S> >::const_iterator &itEnd): 
     
    208210                @param checkDirty if dirty part of the pvs should be checked for entry  
    209211                        (warning: linear runtime in dirty part) 
    210                 @returns iterator on the sample. 
     212                @returns iterator on the sample if found, else the place where  
     213                        it would be added in the sorted vector. 
    211214        */ 
    212215        bool Find(T sample, 
     
    222225 
    223226        /** Adds sample to PVS without checking for presence of the sample 
    224                 pvs remains unsorted! 
     227                warning: pvs remains unsorted! 
    225228        */ 
    226229        void AddSampleDirty(T sample, const float pdf); 
     
    402405void Pvs<T, S>::SimpleSort() 
    403406{ 
    404   //  sort(mEntries.begin(), mEntries.end()); 
    405   std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 
     407        //  sort(mEntries.begin(), mEntries.end()); 
     408        std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 
     409 
     410        sort(it, mEntries.end()); 
     411        inplace_merge(mEntries.begin(), it, mEntries.end()); 
    406412   
    407   sort(it, mEntries.end()); 
    408   inplace_merge(mEntries.begin(), it, mEntries.end()); 
    409    
    410   mLastSorted = (int)mEntries.size(); 
    411   mQueriesSinceSort = 0; 
     413        mLastSorted = (int)mEntries.size(); 
     414        mQueriesSinceSort = 0; 
    412415} 
    413416 
     
    635638                                         const bool checkDirty) 
    636639{ 
    637   PvsEntry<T, S> dummy(sample, PvsData()); 
    638   mQueriesSinceSort++; 
    639    
    640   // only check clean part 
    641   vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 
    642    
    643   // binary search 
    644   it = lower_bound(mEntries.begin(), sorted_end, dummy); 
    645    
    646   if ((it != mEntries.end()) && ((*it).mObject == sample)) 
    647         //  if (it != sorted_end) 
    648         return true; 
    649    
    650   // sample not found yet => search further in the unsorted part 
    651   if (checkDirty) { 
    652          
    653         for (it = sorted_end; (it != mEntries.end()) && ((*it).mObject != sample); ++ it) ; 
    654          
    655         if (it != mEntries.end()) 
    656           return true; 
    657   } 
    658    
    659   return false; 
    660 } 
    661  
     640        bool found = false; 
     641 
     642        PvsEntry<T, S> dummy(sample, PvsData()); 
     643 
     644        // only check clean part 
     645        vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 
     646 
     647        // binary search 
     648        it = lower_bound(mEntries.begin(), sorted_end, dummy); 
     649 
     650        if ((it != mEntries.end()) && ((*it).mObject == sample)) 
     651                found = true; 
     652 
     653        // sample not found yet => search further in the unsorted part 
     654        if (!found && checkDirty)  
     655        { 
     656                vector<PvsEntry<T, S> >::iterator dit, dit_end = mEntries.end(); 
     657 
     658        for (dit = sorted_end; (dit != dit_end) && ((*dit).mObject != sample); ++ dit); 
     659         
     660                if (dit != dit_end) 
     661                { 
     662                        found = true; 
     663                        it = dit; 
     664                } 
     665        } 
     666 
     667        return found; 
     668} 
     669 
     670/* 
     671template <typename T, typename S>  
     672bool Pvs<T, S>::Find(T sample, 
     673                                         typename vector<PvsEntry<T, S> >::iterator &it, 
     674                                         const bool checkDirty) 
     675{ 
     676        PvsEntry<T, S> dummy(sample, PvsData()); 
     677        mQueriesSinceSort++; 
     678 
     679        // only check clean part 
     680        vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 
     681 
     682        // binary search 
     683        it = lower_bound(mEntries.begin(), sorted_end, dummy); 
     684 
     685        if ((it != mEntries.end()) && ((*it).mObject == sample)) 
     686                return true; 
     687 
     688        // sample not found yet => search further in the unsorted part 
     689        if (checkDirty)  
     690        { 
     691                for (it = sorted_end; (it != mEntries.end()) && ((*it).mObject != sample); ++ it); 
     692 
     693                if (it != mEntries.end()) 
     694                        return true; 
     695        } 
     696 
     697        return false; 
     698} 
     699*/ 
    662700 
    663701template <typename T, typename S> 
     
    674712template <typename T, typename S> 
    675713float Pvs<T, S>::AddSample(T sample, const float pdf) 
    676 { 
     714{cout << "t"; 
    677715        ++ mSamples; 
    678716         
     
    687725        } 
    688726        else  
    689           { 
     727        { 
    690728                PvsEntry<T, S> entry(sample, pdf); 
    691729                mEntries.insert(it, entry); 
    692730                ++ mLastSorted; 
    693731                return pdf; 
    694           } 
     732        } 
    695733} 
    696734 
     
    711749         
    712750        vector<PvsEntry<T, S> >::iterator it; 
    713         const bool entryFound == Find(sample, it); 
     751        const bool entryFound = Find(sample, it); 
    714752 
    715753        if (entryFound) 
     
    740778 
    741779        vector<PvsEntry<T, S> >::iterator it; 
    742         bool entryFound = Find(sample, it); 
    743  
    744         if (entryFound) { 
    745           S &data = (*it).mData; 
     780        const bool entryFound = Find(sample, it); 
     781 
     782        if (entryFound)  
     783        { 
     784                S &data = (*it).mData; 
    746785           
    747           data.mSumPdf += pdf; 
    748           //contribution = pdf / data.mSumPdf; 
    749            
    750           return false; 
    751         } 
    752         else { 
    753           AddSampleDirty(sample, pdf); 
    754           //contribution = 1.0f; 
    755           return true; 
     786                data.mSumPdf += pdf; 
     787                //contribution = pdf / data.mSumPdf; 
     788 
     789        return false; 
     790        } 
     791        else  
     792        { 
     793                AddSampleDirty(sample, pdf); 
     794                //contribution = 1.0f; 
     795                 
     796                return true; 
    756797        } 
    757798} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp

    r2049 r2066  
    162162 
    163163        if (samples - lastEvaluation >= mSamplesPerEvaluation) { 
    164           long time = TimeDiff(startTime, GetTime()); 
     164          Real time = TimeDiff(startTime, GetTime()); 
    165165          mViewCellsManager->PrintPvsStatistics(mStats); 
    166166          mStats << 
     
    177177        } 
    178178 
    179         long time = TimeDiff(startTime, GetTime()); 
     179        Real time = TimeDiff(startTime, GetTime()); 
    180180        if (mTotalTime != -1 && time/1000 > mTotalTime) 
    181181          break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2048 r2066  
    389389        Vector3 point; 
    390390        Vector3 normal; 
    391         //cout << "w"; 
     391         
    392392        const int i = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 
    393393 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r2053 r2066  
    7676                                EnableIntrinsicFunctions="TRUE" 
    7777                                FavorSizeOrSpeed="1" 
     78                                OmitFramePointers="TRUE" 
     79                                EnableFiberSafeOptimizations="TRUE" 
    7880                                OptimizeForProcessor="0" 
    7981                                OptimizeForWindowsApplication="TRUE" 
    80                                 AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing" 
     82                                AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing;Timer" 
    8183                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT" 
    8284                                RuntimeLibrary="2" 
    83                                 RuntimeTypeInfo="TRUE" 
     85                                EnableEnhancedInstructionSet="2" 
     86                                RuntimeTypeInfo="FALSE" 
    8487                                UsePrecompiledHeader="0" 
    8588                                BrowseInformation="1" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Timer/merror.h

    r2015 r2066  
    249249#define CHKGL _BLBEGIN GLenum error; \ 
    250250        if ( (error = glGetError()) != GL_NO_ERROR) \ 
    251         EOUT(gluErrorString(error)); _BLEND; 
     251        EOUT("here4 " << gluErrorString(error)); _BLEND; 
    252252 
    253253#ifdef WIN32 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r2017 r2066  
    265265                                                        float &contribution) 
    266266{  
     267        cout<<"e"; 
    267268        const bool result = mPvs.AddSample(sample, pdf);//, contribution); 
    268269        // have to recompute pvs size 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2065 r2066  
    742742        vector<int>::const_iterator iit, iit_end = strategies.end(); 
    743743 
    744         cout << "===============================\n" << endl; 
    745744        for (iit = strategies.begin(); iit != iit_end; ++ iit) 
    746745        { 
     
    760759        // shoot simple ray and add it to importance samples 
    761760        mPreprocessor->CastRays(simpleRays, passSamples, true); 
     761         
    762762        cout << "cast " <<  samplesPerPass << " samples in "  
    763763                 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    764764 
    765         cout << "===============================\n" << endl; 
    766765        return (int)passSamples.size(); 
    767766} 
     
    25982597        } 
    25992598#else 
     2599        cout<<"b"; 
    26002600        pvs.AddSample(obj, pdf); 
    26012601#endif 
     
    26192619                                                                                                   Intersectable *obj, 
    26202620                                                                                                   const Vector3 &pt, 
    2621                                                                                                    const bool addRays) 
     2621                                                                                                   const bool addSamplesToPvs) 
    26222622{ 
    26232623  // check if we are outside of view space 
     
    26352635   
    26362636  // todo: maybe not correct for kd node pvs 
    2637   if (addRays) { 
     2637  if (addSamplesToPvs) { 
    26382638        hasAbsContribution = viewCell->GetPvs().AddSampleDirtyCheck(obj, 
    26392639                                                                                                                                ray.mPdf); 
     2640        //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 
    26402641  } 
    26412642  else { 
     
    26532654        absContribution = relContribution = 1.0f; 
    26542655        if (viewCell->GetPvs().RequiresResort())  
    2655           viewCell->GetPvs().SimpleSort(); 
    2656          
    2657         //        viewCell->GetPvs().SimpleSort(); 
     2656                viewCell->GetPvs().SimpleSort(); 
    26582657 
    26592658#if CONTRIBUTION_RELATIVE_TO_PVS_SIZE 
     
    33103309          { 
    33113310                  Intersectable *o = *noi; 
    3312                   
     3311                  cout<<"w"; 
    33133312                  // $$ JB warning: pdfs are not correct at this point!    
    33143313                  nPvs.AddSample(o, Limits::Small); 
     
    36203619        if (root->IsLeaf()) 
    36213620        {  
    3622                 //cout << "updating leaf" << endl; 
    36233621                // we assume that pvs is explicitly stored in leaves 
    36243622                pvs = root->GetPvs(); 
     
    36343632        // reset interior pvs 
    36353633        interior->GetPvs().Clear(); 
     3634 
    36363635        // reset recursive pvs 
    36373636        pvs.Clear(); 
     
    36553654        Intersectable::NewMail(); 
    36563655 
     3656        /////////// 
    36573657        //-- faster way of computing pvs: 
    36583658        //-- construct merged pvs by adding 
     
    36753675                        if (!intersect->Mailed()) 
    36763676                        {  
    3677                                 pvs.AddSample(intersect, entry.mData.mSumPdf); 
    36783677                                intersect->Mail(); 
     3678 
     3679                                if (pvs.AddSampleDirtyCheck(intersect, entry.mData.mSumPdf)) 
     3680                                { 
     3681                                        if (pvs.RequiresResort()) 
     3682                                        { 
     3683                                                pvs.SimpleSort(); 
     3684                                        } 
     3685                                } 
     3686                                 
    36793687                        } 
    36803688                } 
     
    50875095        } 
    50885096 
    5089         if (mShowVisualization)  
    5090         { 
    5091                 // use pvs size for color coding 
    5092                 mColorCode = 1; 
    5093                 Exporter *exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 
    5094  
    5095                 cout << "exporting view cells after merge (pvs size) ... ";      
    5096  
    5097                 if (exporter) 
    5098                 { 
    5099                         exporter->SetFilled(); 
    5100  
    5101                         ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 
    5102  
    5103                         if (mExportGeometry) 
    5104                         { 
    5105                                 Material m; 
    5106                                 m.mDiffuseColor = RgbColor(0, 1, 0); 
    5107                                 exporter->SetForcedMaterial(m); 
    5108                                 exporter->SetFilled(); 
    5109  
    5110                                 exporter->ExportGeometry(objects); 
    5111                         } 
    5112  
    5113                         delete exporter; 
    5114                 } 
    5115                 cout << "finished" << endl; 
    5116         } 
    5117  
    51185097        mColorCode = savedColorCode; 
    51195098} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r2021 r2066  
    2626#define USE_FIXEDPOINT_T 0 
    2727#define COUNT_ORIGIN_OBJECTS 1 
     28 
     29#define STORE_PVS 0 
    2830 
    2931 
     
    822824                leaf->SetViewCell(viewCell); 
    823825         
    824                 //-- update pvs 
    825                 int conSamp = 0; 
    826                 float sampCon = 0.0f; 
    827                 AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 
    828  
    829                 // update scalar pvs size lookup 
    830                 ObjectPvs &pvs = viewCell->GetPvs(); 
    831                 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.EvalPvsCost(), pvs.GetSize()); 
    832          
    833  
    834                 mBspStats.contributingSamples += conSamp; 
    835                 mBspStats.sampleContributions += (int)sampCon; 
    836  
     826                if (STORE_PVS) 
     827                { 
     828                        ////////// 
     829                        //-- update pvs 
     830 
     831                        int conSamp = 0; 
     832                        float sampCon = 0.0f; 
     833 
     834                        AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 
     835 
     836                        // update scalar pvs size lookup 
     837                        ObjectPvs &pvs = viewCell->GetPvs(); 
     838                        mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.EvalPvsCost(), pvs.GetSize()); 
     839                 
     840                        mBspStats.contributingSamples += conSamp; 
     841                        mBspStats.sampleContributions += (int)sampCon; 
     842                } 
     843 
     844                ////////// 
    837845                //-- store additional info 
     846 
    838847                if (mStoreRays) 
    839848                { 
     
    966975        leaf->SetViewCell(viewCell); 
    967976                 
    968                 //-- update pvs 
    969                 int conSamp = 0; 
    970                 float sampCon = 0.0f; 
    971                 AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 
    972  
    973                 // update scalar pvs size value 
    974                 ObjectPvs &pvs = viewCell->GetPvs(); 
    975                 mViewCellsManager->UpdateScalarPvsSize(viewCell,  
    976                                                                                            pvs.EvalPvsCost(),  
    977                                                                                            pvs.GetSize()); 
    978  
    979                 mBspStats.contributingSamples += conSamp; 
    980                 mBspStats.sampleContributions += (int)sampCon; 
     977                if (STORE_PVS) 
     978                { 
     979                        ///////// 
     980                        //-- update pvs 
     981 
     982            int conSamp = 0; 
     983                        float sampCon = 0.0f; 
     984 
     985                        AddToPvs(leaf, *tData.mRays, sampCon, conSamp); 
     986                 
     987                        // update scalar pvs size value 
     988                        ObjectPvs &pvs = viewCell->GetPvs(); 
     989                        mViewCellsManager->UpdateScalarPvsSize(viewCell,  
     990                                                                                                   pvs.EvalPvsCost(),  
     991                                                                                                   pvs.GetSize()); 
     992                         
     993                        mBspStats.contributingSamples += conSamp; 
     994                        mBspStats.sampleContributions += (int)sampCon; 
     995                } 
    981996 
    982997                viewCell->mLeaves.push_back(leaf); 
     
    12541269                if (ray->mTerminationObject)  
    12551270                { 
     1271                        cout << "m"; 
    12561272                        if (vc->AddPvsSample(ray->mTerminationObject, ray->mPdf, contribution)) 
    12571273                                madeContrib = true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r2064 r2066  
    10181018 
    10191019                if (entry)  
    1020                 { 
     1020                {cout<<"a"; 
    10211021                        madeContrib =  
    10221022                                vc->GetPvs().AddSample(entry, ray->mPdf); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r2065 r2066  
    624624{ 
    625625        //Preprocessor::DeterminePvsObjects(rays); 
    626  
    627         cout << "here4"; 
    628626        mViewCellsManager->DeterminePvsObjects(rays, true); 
    629627} 
Note: See TracChangeset for help on using the changeset viewer.