Changeset 1077


Ignore:
Timestamp:
07/05/06 16:21:45 (18 years ago)
Author:
mattausch
Message:

worked on object space /view space partitioning

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/TestPreprocessor.vcproj

    r1076 r1077  
    8686                                LinkIncremental="1" 
    8787                                AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)";"$(GTPDIR)\NonGTP\Xerces";"$(GTPDIR)\NonGTP\Xerces\xercesc\lib";"$(GTPDIR)\NonGTP\zlib\lib";"$(GTPDIR)\NonGTP\Devil\lib";..\lib\release;..\..\Preprocessing\lib\release" 
    88                                 GenerateDebugInformation="TRUE" 
     88                                GenerateDebugInformation="FALSE" 
    8989                                SubSystem="1" 
    9090                                OptimizeReferences="2" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1074 r1077  
    2828  KdPvs mKdPvs; 
    2929   
     30  ViewCellPvs mViewCellPvs; 
     31 
    3032  /// kd leaves that this intersectable belongs to 
    3133  set<KdLeaf *> mKdLeaves; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1001 r1077  
    1111class Ray; 
    1212class Intersectable; 
    13 class ViewCellKdNode; 
     13class ViewCell; 
     14 
    1415 
    1516template<typename T> 
     
    415416}; 
    416417 
     418 
     419//-- typedefs 
     420 
    417421typedef std::map<KdNode *, PvsData<KdNode *>, LtSample<KdNode *> > KdPvsMap; 
    418422typedef std::map<Intersectable *, PvsData<Intersectable *>, LtSample<Intersectable *> > ObjectPvsMap; 
     423typedef std::map<ViewCell *, PvsData<ViewCell *>, LtSample<ViewCell *> > ViewCellPvsMap; 
     424 
    419425typedef PvsData<Intersectable *> ObjectPvsData; 
    420426typedef PvsData<KdNode *> KdPvsData; 
    421427 
    422428typedef Pvs<Intersectable *> ObjectPvs; 
    423  
     429typedef Pvs<ViewCell *> ViewCellPvs; 
    424430} 
    425431 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1074 r1077  
    386386{ 
    387387        int numSamples = 0; 
     388 
    388389        SimpleRayContainer simpleRays; 
    389          
    390390        VssRayContainer initialSamples; 
    391391 
     
    426426 
    427427 
    428         if (1) // export initial view cells 
     428        if (0) // export initial view cells 
    429429        { 
    430430                const char filename[] = "view_cells.wrl"; 
     
    524524 
    525525        //-- post processing (e.g.,merging) of the view cells 
    526         PostProcess(preprocessor->mObjects, postProcessSamples); 
     526        if (1) PostProcess(preprocessor->mObjects, postProcessSamples); 
    527527 
    528528        cout << "time needed for post processing (merge) step: " 
     
    30753075                                                                                  const ObjectContainer &objects) 
    30763076{ 
    3077 #if STILL_HAS_TODO 
     3077#if TODO 
    30783078        cout << "exporting view cells to xml ... "; 
    30793079        std::ofstream stream; 
     
    36733673        cout << "construction finished" << endl; 
    36743674 
    3675         // real meshes are contructed at this stage 
     3675         
    36763676        if (0) 
    36773677        { 
     3678                //-- real meshes are contructed at this stage 
    36783679                cout << "finalizing view cells ... "; 
    36793680                FinalizeViewCells(true); 
     
    37693770        } 
    37703771 
    3771         if (1) // export merged view cells using pvs coding 
     3772        if (0) // export merged view cells using pvs coding 
    37723773        { 
    37733774                mColorCode = 1; 
     
    41584159        GetRaySets(sampleRays, mVisualizationSamples, visRays); 
    41594160 
    4160         //-- export view cells 
    4161         if (1)  
     4161        //-- export final view cell partition 
     4162 
     4163        if (0)  
    41624164        {        
    41634165                // hack pvs 
     
    52275229        GetRaySets(sampleRays, mVisualizationSamples, visRays); 
    52285230 
    5229         //-- export view cells 
     5231        //-- export final view cells 
     5232 
    52305233        if (1)  
    52315234        {        
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1076 r1077  
    1818#include "Beam.h" 
    1919 
     20 
     21 
    2022namespace GtpVisibilityPreprocessor { 
     23 
    2124 
    2225#define USE_FIXEDPOINT_T 0 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1076 r1077  
    4040        if (pvs < lower) 
    4141                return (float)lower; 
    42         if (pvs > upper) 
     42        else if (pvs > upper) 
    4343                return (float)upper; 
    4444 
     
    778778                        ++ contributingSamples; 
    779779                 
    780                 // warning: rays get never deleted! 
    781                 if (1) leaf->mVssRays.push_back(new VssRay(*ray)); 
     780                // store rays for visualization 
     781                if (0) leaf->mVssRays.push_back(new VssRay(*ray)); 
    782782        } 
    783783} 
     
    992992 
    993993 
    994 float VspTree::EvalLocalCostHeuristics(const RayInfoContainer &rays, 
    995                                                                            const AxisAlignedBox3 &box, 
    996                                                                            int pvsSize, 
    997                                                                            const int axis, 
    998                                                                            float &position) 
    999 { 
    1000         const float minBox = box.Min(axis); 
    1001         const float maxBox = box.Max(axis); 
    1002  
    1003         const float sizeBox = maxBox - minBox; 
    1004  
    1005         const float minBand = minBox + mMinBand * sizeBox; 
    1006         const float maxBand = minBox + mMaxBand * sizeBox; 
    1007  
    1008         SortSplitCandidates(rays, axis, minBand, maxBand); 
    1009  
    1010         // go through the lists, count the number of objects left and right 
    1011         // and evaluate the following cost funcion: 
    1012         // C = ct_div_ci  + (ql*rl + qr*rr)/queries 
    1013  
    1014         int pvsl = 0; 
    1015         int pvsr = pvsSize; 
    1016  
    1017         int pvsBack = pvsl; 
    1018         int pvsFront = pvsr; 
    1019  
    1020         float sum = (float)pvsSize * sizeBox; 
    1021         float minSum = 1e20f; 
    1022  
    1023          
    1024         // if no good split can be found, take mid split 
    1025         position = minBox + 0.5f * sizeBox; 
    1026          
    1027         // the relative cost ratio 
    1028         float ratio = 99999999.0f; 
    1029         bool splitPlaneFound = false; 
    1030  
    1031         Intersectable::NewMail(); 
    1032  
    1033         RayInfoContainer::const_iterator ri, ri_end = rays.end(); 
    1034  
    1035         //-- set all object as belonging to the front pvs 
    1036  
    1037         for(ri = rays.begin(); ri != ri_end; ++ ri) 
    1038         { 
    1039                 Intersectable *oObject = (*ri).mRay->mOriginObject; 
    1040                 Intersectable *tObject = (*ri).mRay->mTerminationObject; 
    1041  
    1042                 if (oObject) 
    1043                 { 
    1044                         if (!oObject->Mailed()) 
    1045                         { 
    1046                                 oObject->Mail(); 
    1047                                 oObject->mCounter = 1; 
    1048                         } 
    1049                         else 
    1050                         { 
    1051                                 ++ oObject->mCounter; 
    1052                         } 
    1053                 } 
    1054                 if (tObject) 
    1055                 { 
    1056                         if (!tObject->Mailed()) 
    1057                         { 
    1058                                 tObject->Mail(); 
    1059                                 tObject->mCounter = 1; 
    1060                         } 
    1061                         else 
    1062                         { 
    1063                                 ++ tObject->mCounter; 
    1064                         } 
    1065                 } 
    1066         } 
    1067  
    1068         Intersectable::NewMail(); 
    1069  
    1070         vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 
    1071  
    1072         for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci) 
    1073         { 
    1074                 VssRay *ray; 
    1075                 ray = (*ci).ray; 
    1076                  
    1077                 Intersectable *oObject = ray->mOriginObject; 
    1078                 Intersectable *tObject = ray->mTerminationObject; 
    1079                  
    1080  
    1081                 switch ((*ci).type) 
    1082                 { 
    1083                         case SortableEntry::ERayMin: 
    1084                                 { 
    1085                                         if (oObject && !oObject->Mailed()) 
    1086                                         { 
    1087                                                 oObject->Mail(); 
    1088                                                 ++ pvsl; 
    1089                                         } 
    1090                                         if (tObject && !tObject->Mailed()) 
    1091                                         { 
    1092                                                 tObject->Mail(); 
    1093                                                 ++ pvsl; 
    1094                                         } 
    1095                                         break; 
    1096                                 } 
    1097                         case SortableEntry::ERayMax: 
    1098                                 { 
    1099                                         if (oObject) 
    1100                                         { 
    1101                                                 if (-- oObject->mCounter == 0) 
    1102                                                         -- pvsr; 
    1103                                         } 
    1104  
    1105                                         if (tObject) 
    1106                                         { 
    1107                                                 if (-- tObject->mCounter == 0) 
    1108                                                         -- pvsr; 
    1109                                         } 
    1110  
    1111                                         break; 
    1112                                 } 
    1113                 } 
    1114                  
    1115                  
    1116                 // Note: sufficient to compare size of bounding boxes of front and back side? 
    1117                 if (((*ci).value >= minBand) && ((*ci).value <= maxBand)) 
    1118                 { 
    1119                         sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
    1120  
    1121                         //Debug  << "pos=" << (*ci).value << "\t pvs=(" <<  pvsl << "," << pvsr << ")" << endl; 
    1122                         //Debug << "cost= " << sum << endl; 
    1123  
    1124                         if (sum < minSum) 
    1125                         { 
    1126                                 splitPlaneFound = true; 
    1127  
    1128                                 minSum = sum; 
    1129                                 position = (*ci).value; 
    1130                                  
    1131                                 pvsBack = pvsl; 
    1132                                 pvsFront = pvsr; 
    1133                         } 
    1134                 } 
    1135         } 
    1136          
    1137          
    1138         // -- compute cost 
    1139  
    1140         const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
    1141         const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
    1142  
    1143         const float pOverall = sizeBox; 
    1144         const float pBack = position - minBox; 
    1145         const float pFront = maxBox - position; 
    1146  
    1147          
    1148         const float penaltyOld = EvalPvsPenalty(pvsSize, lowerPvsLimit, upperPvsLimit); 
    1149     const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
    1150         const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
    1151          
    1152         const float oldRenderCost = penaltyOld * pOverall + Limits::Small; 
    1153         const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
    1154  
    1155         if (splitPlaneFound) 
    1156         { 
    1157                 ratio = newRenderCost / oldRenderCost; 
    1158         } 
    1159         //if (axis != 1) 
    1160         //Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 
    1161          //    <<"\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 
    1162  
    1163         return ratio; 
    1164 } 
    1165  
    1166  
    1167994void VspTree::RemoveContriFromPvs(KdLeaf *leaf, int &pvs) const 
    1168995{ 
     
    11941021                leaf->Mail(); 
    11951022 
    1196                 // add objects without objects which are part of several kd leaves 
     1023                // add objects without those which are part of several kd leaves 
    11971024                pvs += ((int)leaf->mObjects.size() - (int)leaf->mMultipleObjects.size()); 
    11981025 
     
    12861113                { 
    12871114                        set<KdLeaf *>::const_iterator kit, kit_end = tObject->mKdLeaves.end(); 
    1288  
     1115                         
    12891116                        for (kit = tObject->mKdLeaves.begin(); kit != kit_end; ++ kit) 
    12901117                        { 
     
    13051132 
    13061133 
    1307 /* 
    13081134float VspTree::EvalLocalCostHeuristics(const RayInfoContainer &rays, 
    13091135                                                                           const AxisAlignedBox3 &box, 
     
    13221148        SortSplitCandidates(rays, axis, minBand, maxBand); 
    13231149 
    1324         // prepare the heuristics sweep  
     1150        // prepare the sweep 
    13251151        // (note: returns pvs size, so there would be no need  
    13261152        // to give pvs size as argument) 
     
    14101236 
    14111237        return ratio; 
    1412 }*/ 
     1238} 
    14131239 
    14141240 
     
    30162842 
    30172843 
     2844/* 
     2845float OspTree::EvalLocalCostHeuristics(const RayInfoContainer &rays, 
     2846                                                                           const AxisAlignedBox3 &box, 
     2847                                                                           int pvsSize, 
     2848                                                                           const int axis, 
     2849                                                                           float &position) 
     2850{ 
     2851        const float minBox = box.Min(axis); 
     2852        const float maxBox = box.Max(axis); 
     2853 
     2854        const float sizeBox = maxBox - minBox; 
     2855 
     2856        const float minBand = minBox + mMinBand * sizeBox; 
     2857        const float maxBand = minBox + mMaxBand * sizeBox; 
     2858 
     2859        SortSplitCandidates(rays, axis, minBand, maxBand); 
     2860 
     2861        // prepare the sweep  
     2862        // (note: returns pvs size, so there would be no need  
     2863        // to give pvs size as argument) 
     2864        pvsSize = PrepareHeuristics(rays); 
     2865 
     2866        Debug << "here45 pvs: " << pvsSize << endl; 
     2867 
     2868        // go through the lists, count the number of objects left and right 
     2869        // and evaluate the following cost funcion: 
     2870        // C = ct_div_ci  + (ql*rl + qr*rr)/queries 
     2871 
     2872        int pvsl = 0; 
     2873        int pvsr = pvsSize; 
     2874 
     2875        int pvsBack = pvsl; 
     2876        int pvsFront = pvsr; 
     2877 
     2878        float sum = (float)pvsSize * sizeBox; 
     2879        float minSum = 1e20f; 
     2880 
     2881         
     2882        // if no good split can be found, take mid split 
     2883        position = minBox + 0.5f * sizeBox; 
     2884         
     2885        // the relative cost ratio 
     2886        float ratio = 99999999.0f; 
     2887        bool splitPlaneFound = false; 
     2888 
     2889        Intersectable::NewMail(); 
     2890        KdLeaf::NewMail(); 
     2891 
     2892 
     2893        vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 
     2894 
     2895        //-- traverse through visibility events 
     2896        for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci) 
     2897        { 
     2898                EvalPvsIncr(*ci, pvsl, pvsr); 
     2899 
     2900                // Note: sufficient to compare size of bounding boxes of front and back side? 
     2901                if (((*ci).value >= minBand) && ((*ci).value <= maxBand)) 
     2902                { 
     2903                        sum = pvsl * ((*ci).value - minBox) + pvsr * (maxBox - (*ci).value); 
     2904 
     2905                        //Debug  << "pos=" << (*ci).value << "\t pvs=(" <<  pvsl << "," << pvsr << ")" << "\t cost= " << sum << endl; 
     2906 
     2907                        if (sum < minSum) 
     2908                        { 
     2909                                splitPlaneFound = true; 
     2910 
     2911                                minSum = sum; 
     2912                                position = (*ci).value; 
     2913                                 
     2914                                pvsBack = pvsl; 
     2915                                pvsFront = pvsr; 
     2916                        } 
     2917                } 
     2918        } 
     2919         
     2920         
     2921        // -- compute cost 
     2922 
     2923        const int lowerPvsLimit = mViewCellsManager->GetMinPvsSize(); 
     2924        const int upperPvsLimit = mViewCellsManager->GetMaxPvsSize(); 
     2925 
     2926        const float pOverall = sizeBox; 
     2927        const float pBack = position - minBox; 
     2928        const float pFront = maxBox - position; 
     2929 
     2930        const float penaltyOld = EvalPvsPenalty(pvsSize, lowerPvsLimit, upperPvsLimit); 
     2931    const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
     2932        const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
     2933         
     2934        const float oldRenderCost = penaltyOld * pOverall + Limits::Small; 
     2935        const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
     2936 
     2937        if (splitPlaneFound) 
     2938        { 
     2939                ratio = newRenderCost / oldRenderCost; 
     2940        } 
     2941         
     2942        //if (axis != 1) 
     2943        Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 
     2944              <<"\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 
     2945 
     2946        return ratio; 
     2947} 
     2948*/ 
     2949 
     2950float OspTree::EvalLocalCostHeuristics(BspLeaf *node, 
     2951                                                                           const AxisAlignedBox3 &box, 
     2952                                                                           const int axis, 
     2953                                                                           float &position, 
     2954                                                                           int &objectsBack, 
     2955                                                                           int &objectsFront) 
     2956{ 
     2957         
     2958        /*SortSplitCandidates(node, axis); 
     2959   
     2960        // go through the lists, count the number of objects left and right 
     2961        // and evaluate the following cost funcion: 
     2962        // C = ct_div_ci  + (ol + or)/queries 
     2963 
     2964        float totalIntersections = 0.0f; 
     2965         
     2966        vector<SortableEntry>::const_iterator ci, ci_end = splitCandidates.end(); 
     2967 
     2968        for(ci = splitCandidates->begin(); ci != ci_end; ++ ci) 
     2969        { 
     2970                 if ((*ci).type == SortableEntry::BOX_MIN)  
     2971                 { 
     2972                         totalIntersections += (*ci).intersectable->IntersectionComplexity(); 
     2973                 } 
     2974        } 
     2975         
     2976        float intersectionsLeft = 0; 
     2977        float intersectionsRight = totalIntersections; 
     2978 
     2979         
     2980        int objectsLeft = 0, objectsRight = (int)node->mObjects.size(); 
     2981   
     2982        float minBox = box.Min(axis); 
     2983        float maxBox = box.Max(axis); 
     2984         
     2985        float boxArea = box.SurfaceArea(); 
     2986   
     2987        float minBand = minBox + mSplitBorder*(maxBox - minBox); 
     2988        float maxBand = minBox + (1.0f - mSplitBorder)*(maxBox - minBox); 
     2989 
     2990    float minSum = 1e20f; 
     2991   
     2992        for(ci = splitCandidates->begin(); ci != ci_end; ++ ci) 
     2993        { 
     2994                EvalPvsIncr(ci, pvsl, pvsr); 
     2995 
     2996                if ((*ci).value > minBand && (*ci).value < maxBand)  
     2997                { 
     2998                        AxisAlignedBox3 lbox = box; 
     2999                        AxisAlignedBox3 rbox = box; 
     3000                         
     3001                        lbox.SetMax(axis, (*ci).value); 
     3002                        rbox.SetMin(axis, (*ci).value); 
     3003 
     3004                        float sum; 
     3005                         
     3006                        if (mSahUseFaces) 
     3007                                sum = intersectionsLeft*lbox.SurfaceArea() + intersectionsRight*rbox.SurfaceArea(); 
     3008                        else 
     3009                                sum = objectsLeft*lbox.SurfaceArea() + objectsRight*rbox.SurfaceArea(); 
     3010       
     3011                        //      cout<<"pos="<<(*ci).value<<"\t q=("<<ql<<","<<qr<<")\t r=("<<rl<<","<<rr<<")"<<endl; 
     3012                        //      cout<<"cost= "<<sum<<endl; 
     3013       
     3014                        if (sum < minSum)  
     3015                        { 
     3016                                minSum = sum; 
     3017                                position = (*ci).value; 
     3018 
     3019                                objectsBack = objectsLeft; 
     3020                                objectsFront = objectsRight; 
     3021                        } 
     3022                } 
     3023        } 
     3024   
     3025        float oldCost = mSahUseFaces ? totalIntersections : node->mObjects.size(); 
     3026        float newCost = mCt_div_ci + minSum/boxArea; 
     3027        float ratio = newCost/oldCost; 
     3028   
     3029#if 0 
     3030        cout<<"===================="<<endl; 
     3031        cout<<"costRatio="<<ratio<<" pos="<<position<<" t="<<(position - minBox)/(maxBox - minBox) 
     3032                <<"\t o=("<<objectsBack<<","<<objectsFront<<")"<<endl; 
     3033#endif 
     3034         
     3035        return ratio; 
     3036        */ 
     3037        return 0; 
     3038} 
     3039 
     3040 
     3041void OspTree::SortSplitCandidates(const RayInfoContainer &rays, 
     3042                                                                  const int axis,  
     3043                                                                  float minBand,  
     3044                                                                  float maxBand) 
     3045{ 
     3046        // TODO 
     3047} 
     3048 
     3049 
     3050 
     3051int OspTree::PrepareHeuristics(Intersectable *object) 
     3052{ 
     3053        ViewCellPvsMap::const_iterator vit, vit_end = object->mViewCellPvs.mEntries.end(); 
     3054         
     3055        int pvsSize = 0; 
     3056 
     3057        for (vit = object->mViewCellPvs.mEntries.begin(); vit != vit_end; ++ vit) 
     3058        { 
     3059        ViewCell *vc = (*vit).first; 
     3060 
     3061                if (!vc->Mailed()) 
     3062                { 
     3063                        vc->Mail(); 
     3064                        vc->mCounter = 1; 
     3065                        ++ pvsSize; 
     3066                } 
     3067                else 
     3068                { 
     3069                        ++ vc->mCounter; 
     3070                } 
     3071        } 
     3072 
     3073        return pvsSize; 
     3074} 
     3075 
     3076 
     3077int OspTree::PrepareHeuristics(const RayInfoContainer &rays) 
     3078{        
     3079        Intersectable::NewMail(); 
     3080        KdNode::NewMail(); 
     3081 
     3082        int pvsSize = 0; 
     3083 
     3084        RayInfoContainer::const_iterator ri, ri_end = rays.end(); 
     3085 
     3086        //-- set all kd nodes as belonging to the front pvs 
     3087 
     3088        for (ri = rays.begin(); ri != ri_end; ++ ri) 
     3089        { 
     3090                Intersectable *oObject = (*ri).mRay->mOriginObject; 
     3091 
     3092                if (oObject) 
     3093                { 
     3094                        pvsSize += PrepareHeuristics(oObject);           
     3095                } 
     3096 
     3097                Intersectable *tObject = (*ri).mRay->mTerminationObject; 
     3098 
     3099                if (tObject) 
     3100                { 
     3101                        pvsSize += PrepareHeuristics(tObject);   
     3102                } 
     3103        } 
     3104 
     3105        return pvsSize; 
     3106} 
     3107 
     3108 
     3109void OspTree::EvalPvsIncr(const SortableEntry &ci, 
     3110                                                  int &pvsLeft, 
     3111                                                  int &pvsRight) const 
     3112{ 
     3113        Intersectable *obj = ci.mObject; 
     3114 
     3115        switch (ci.type)  
     3116        { 
     3117                case SortableEntry::BOX_MIN: 
     3118                        AddContriToPvs(obj, pvsLeft); 
     3119                        break; 
     3120                         
     3121                case SortableEntry::BOX_MAX: 
     3122                        RemoveContriFromPvs(obj, pvsRight); 
     3123                        break; 
     3124        } 
     3125} 
     3126 
     3127 
     3128void OspTree::RemoveContriFromPvs(Intersectable *object, int &pvs) const 
     3129{ 
     3130        ViewCellPvsMap::const_iterator vit, vit_end = object->mViewCellPvs.mEntries.end(); 
     3131         
     3132        for (vit = object->mViewCellPvs.mEntries.begin(); vit != vit_end; ++ vit) 
     3133        { 
     3134        ViewCell *vc = (*vit).first; 
     3135 
     3136                if (-- vc->mCounter == 0) 
     3137                { 
     3138                        -- pvs; 
     3139                } 
     3140        } 
     3141} 
     3142 
     3143 
     3144void OspTree::AddContriToPvs(Intersectable *object, int &pvs) const 
     3145{ 
     3146        ViewCellPvsMap::const_iterator vit, vit_end = object->mViewCellPvs.mEntries.end(); 
     3147 
     3148        for (vit = object->mViewCellPvs.mEntries.begin(); vit != vit_end; ++ vit) 
     3149        { 
     3150        ViewCell *vc = (*vit).first; 
     3151 
     3152                if (!vc->Mailed()) 
     3153                { 
     3154                        vc->Mail();              
     3155                        ++ pvs; 
     3156                } 
     3157        } 
     3158} 
     3159 
    30183160 
    30193161/*********************************************************************/ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1074 r1077  
    882882                                                         float maxBand); 
    883883 
    884         /** Prepares objects for SAH. 
    885                 @returns pvs size of the ray container 
    886         */ 
    887         int PrepareHeuristics(const RayInfoContainer &rays); 
    888  
    889         int PrepareHeuristics(Intersectable *object); 
    890  
    891884        /** Computes pvs increase with respect to the previous pvs for SAH. 
    892885        */ 
     
    916909        void RemoveContriFromPvs(KdLeaf *leaf, int &pvs) const; 
    917910        void AddContriToPvs(KdLeaf *leaf, int &pvs) const; 
     911 
     912        /** Prepares objects for SAH. 
     913                @returns pvs size of the ray container 
     914        */ 
     915        int PrepareHeuristics(const RayInfoContainer &rays); 
     916 
     917        int PrepareHeuristics(Intersectable *object); 
    918918 
    919919        /** Subdivides the rays into front and back rays according to the split plane. 
     
    13331333        // For sorting objects 
    13341334        // -------------------------------------------------------------- 
    1335         struct SortableEntry 
     1335        struct  SortableEntry 
    13361336        { 
    1337                 enum EType  
     1337                enum 
    13381338                { 
    1339                         ERayMin, 
    1340                         ERayMax 
     1339                        BOX_MIN, 
     1340                        BOX_MAX 
    13411341                }; 
    13421342 
    13431343                int type; 
    13441344                float value; 
    1345                 VssRay *ray; 
    1346    
     1345                Intersectable *mObject; 
     1346 
    13471347                SortableEntry() {} 
    1348                 SortableEntry(const int t, const float v, VssRay *r):type(t), 
    1349                                           value(v), ray(r)  
     1348 
     1349                SortableEntry(const int t, const float v, Intersectable *obj): 
     1350                type(t), value(v), mObject(obj)  
     1351                {} 
     1352 
     1353                bool operator<(const SortableEntry &b) const  
    13501354                { 
    1351                 } 
    1352                  
    1353                 friend bool operator<(const SortableEntry &a, const SortableEntry &b)  
    1354                 { 
    1355                         return a.value < b.value; 
     1355                        return value < b.value; 
    13561356                } 
    13571357        }; 
    13581358 
     1359  
    13591360        /** faster evaluation of split plane cost for kd axis aligned cells. 
    13601361        */ 
     
    14491450        /** Computes best cost for axis aligned planes. 
    14501451        */ 
    1451         float EvalLocalCostHeuristics(const RayInfoContainer &rays, 
     1452/*      float EvalLocalCostHeuristics(const RayInfoContainer &rays, 
    14521453                                                                  const AxisAlignedBox3 &box, 
    14531454                                                                  const int pvsSize, 
    14541455                                                                  const int axis, 
    14551456                                                                  float &position); 
     1457*/ 
     1458        float EvalLocalCostHeuristics(BspLeaf *node, 
     1459                const AxisAlignedBox3 &box, 
     1460                const int axis, 
     1461                float &position, 
     1462                int &objectsBack, 
     1463                int &objectsFront); 
    14561464 
    14571465        /** Subdivides the rays into front and back rays according to the split plane. 
     
    15231531        float GetMemUsage() const; 
    15241532 
     1533        /** Evaluates the influence on the pvs of the visibility event ve. 
     1534                @param ve the visibility event 
     1535                @param pvsLeft updates the left pvs 
     1536                @param rightPvs updates the right pvs 
     1537        */ 
     1538        void EvalPvsIncr(const SortableEntry &ve, 
     1539                                          int &pvsLeft, 
     1540                                          int &pvsRight) const; 
     1541 
     1542        void RemoveContriFromPvs(Intersectable *object, int &pvs) const; 
     1543        void AddContriToPvs(Intersectable *object, int &pvs) const; 
     1544 
     1545        /** Prepares objects for SAH. 
     1546                @returns pvs size of the ray container 
     1547        */ 
     1548        int PrepareHeuristics(const RayInfoContainer &rays); 
     1549 
     1550        int PrepareHeuristics(Intersectable *object); 
    15251551 
    15261552protected: 
Note: See TracChangeset for help on using the changeset viewer.