Changeset 335


Ignore:
Timestamp:
10/18/05 02:06:28 (19 years ago)
Author:
mattausch
Message:

reprogrammed splitplane evaluation. updated default.env

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
7 edited

Legend:

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

    r332 r335  
    113113        #splitPlaneStrategy 130 
    114114         
    115         splitPlaneStrategy 66 
     115        splitPlaneStrategy 130 
    116116         
    117         maxCandidates 130 
     117        maxCandidates 50 
    118118         
    119119        Termination { 
    120120                # autopartition 
    121121                maxRays -1 
    122                 maxPolygons 4 
     122                maxPolygons 20 
    123123                maxDepth 100 
    124124                 
    125125                #axis aligned split 
    126                 maxPolysForAxisAligned 100 
     126                maxPolysForAxisAligned 200 
    127127                maxCostRatio 0.9 
    128128                ct_div_ci 0.5 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r333 r335  
    2626 
    2727void 
    28 SamplingPreprocessor::SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction) 
     28SamplingPreprocessor::SetupRay(Ray &ray,  
     29                                                           const Vector3 &point,  
     30                                                           const Vector3 &direction, 
     31                                                           const int type) 
    2932{ 
    3033  ray.intersections.clear(); 
     
    3437 
    3538  //  cout<<point<<" "<<direction<<endl; 
    36   ray.Init(point, direction, Ray::LOCAL_RAY); 
     39  ray.Init(point, direction, type); 
    3740} 
    3841 
     
    259262                Vector3 target = t*poly.mVertices[edge] + (1.0f-t)*poly.mVertices[(edge + 1)% 
    260263                                                                                                                                                                                                                                                                                 poly.mVertices.size()]; 
    261                 SetupRay(ray, point, target - point); 
     264                SetupRay(ray, point, target - point, Ray::LOCAL_RAY); 
    262265                if (!mesh->CastRay(ray, mi)) { 
    263266                        // the rays which intersect the mesh have been discarded since they are not tangent 
     
    395398                                         
    396399                                        // construct a ray 
    397                                         SetupRay(ray, point, direction); 
     400                                        SetupRay(ray, point, direction, Ray::LOCAL_RAY); 
    398401                                         
    399402                                        sampleContributions = CastRay(object, ray); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h

    r333 r335  
    3434 
    3535  void 
    36   SetupRay(Ray &ray, const Vector3 &point, const Vector3 &direction); 
     36  SetupRay(Ray &ray,  
     37                   const Vector3 &point,  
     38                   const Vector3 &direction, 
     39                   const int type); 
    3740 
    3841  KdNode * 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r332 r335  
    10591059                 
    10601060                // evaluate current candidate 
    1061                 float candidateCost = SplitPlaneCost(polys, candidatePlane, rays); 
     1061                float candidateCost = SplitPlaneCost(candidatePlane, polys, rays); 
    10621062                         
    10631063                if (candidateCost < lowestCost) 
     
    10851085} 
    10861086 
    1087 float BspTree::SplitPlaneCost(PolygonContainer &polys,  
    1088                                                           const Plane3 &candidatePlane,  
    1089                                                           const RayContainer &rays) 
     1087float BspTree::SplitPlaneCost(const Plane3 &candidatePlane,  
     1088                                                          const PolygonContainer &polys) const 
    10901089{ 
    10911090        float val = 0; 
    1092  
    1093         if (sSplitPlaneStrategy & VERTICAL_AXIS) 
    1094         { 
    1095                 Vector3 tinyAxis(0,0,0); tinyAxis[mBox.Size().TinyAxis()] = 1.0f; 
    1096                 // we put a penalty on the dot product between the "tiny" vertical axis 
    1097                 // and the split plane axis 
    1098                 val += sVerticalSplitsFactor *  
    1099                            fabs(DotProd(candidatePlane.mNormal, tinyAxis)); 
    1100         } 
    1101  
    1102         if (!((sSplitPlaneStrategy & BALANCED_POLYS)      || 
    1103                   (sSplitPlaneStrategy & LEAST_SPLITS)        || 
    1104                   (sSplitPlaneStrategy & LARGEST_POLY_AREA)   || 
    1105                   (sSplitPlaneStrategy & BALANCED_VIEW_CELLS) || 
    1106                   (sSplitPlaneStrategy & BLOCKED_RAYS))) 
    1107         { 
    1108                 return val; 
    1109         } 
    1110  
    1111         // -- strategies where the effect of the split plane is tested 
    1112         // on all input polygons  
    11131091 
    11141092        float sumBalancedPolys = 0; 
     
    11191097        float totalBlockedRays = 0; 
    11201098        //float totalArea = 0; 
    1121  
    1122         // container for balanced view cells criterium 
    1123         ObjectContainer frontViewCells; 
    1124         ObjectContainer backViewCells; 
    1125  
     1099        int totalViewCells = 0; 
     1100 
     1101        ViewCell::NewMail(); 
     1102         
    11261103        PolygonContainer::const_iterator it, it_end = polys.end(); 
    11271104 
     
    11591136                        MeshInstance *viewCell = (*it)->mParent; 
    11601137                 
    1161                         if (classification == Plane3::FRONT_SIDE) 
    1162                                 frontViewCells.push_back(viewCell); 
    1163                         else if (viewCell && (classification == Plane3::BACK_SIDE)) 
    1164                                 backViewCells.push_back(viewCell); 
     1138                        if (!viewCell->Mailed()) 
     1139                        { 
     1140                                viewCell->Mail(); 
     1141 
     1142                                if (classification == Plane3::FRONT_SIDE) 
     1143                                        sumBalancedViewCells += 1.0f; 
     1144                                else if (viewCell && (classification == Plane3::BACK_SIDE)) 
     1145                                        sumBalancedViewCells -= 1.0f; 
     1146                                ++ totalViewCells; 
     1147                        } 
    11651148                } 
    11661149        } 
     
    11791162 
    11801163        if (sSplitPlaneStrategy & BLOCKED_RAYS) 
    1181                 if (totalBlockedRays > 0) 
     1164                if (totalBlockedRays != 0) 
    11821165                        val += sBlockedRaysFactor * sumBlockedRays / totalBlockedRays; 
    11831166 
    11841167        if (sSplitPlaneStrategy & BALANCED_VIEW_CELLS) 
    1185         { 
    1186                 // count number of unique view cells 
    1187                 sort(frontViewCells.begin(), frontViewCells.end()); 
    1188                 sort(backViewCells.begin(), backViewCells.end()); 
    1189  
    1190                 ObjectContainer::const_iterator frontIt, frontIt_end = frontViewCells.end(); 
    1191          
    1192                 Intersectable *vc = NULL; 
    1193                 // increase counter for view cells in front of plane 
    1194                 for (frontIt = frontViewCells.begin(); frontIt != frontIt_end; ++frontIt) 
    1195                 { 
    1196                         if (*frontIt != vc) 
    1197                         { 
    1198                                 vc = *frontIt; 
    1199                                 sumBalancedViewCells += 1.0f; 
    1200                         } 
    1201                 } 
    1202  
    1203                 ObjectContainer::const_iterator backIt, backIt_end = backViewCells.end(); 
    1204                 vc = NULL; 
    1205                 // decrease counter for view cells on back side of plane 
    1206                 for (backIt = backViewCells.begin(); backIt != backIt_end; ++backIt) 
    1207                 { 
    1208                         if (*backIt != vc) 
    1209                         { 
    1210                                 vc = *backIt; 
    1211                                 sumBalancedViewCells -= 1.0f; 
    1212                         } 
    1213                 } 
    1214  
    1215                 val += sBalancedViewCellsFactor * fabs(sumBalancedViewCells) /  
    1216                         (float)(frontViewCells.size() + backViewCells.size()); 
    1217         } 
     1168                if (totalViewCells != 0) 
     1169                        val += sBalancedViewCellsFactor * fabs(sumBalancedViewCells) /  
     1170                                (float)totalViewCells; 
     1171         
     1172        return val; 
     1173} 
     1174 
     1175float BspTree::SplitPlaneCost(const Plane3 &candidatePlane,  
     1176                                                          const RayContainer &rays) const 
     1177{ 
     1178        float val = 0; 
    12181179 
    12191180        float sumBalancedRays = 0; 
     
    12321193                } 
    12331194        } 
     1195 
    12341196        if (sSplitPlaneStrategy & LEAST_RAY_SPLITS) 
    12351197                if (!rays.empty()) 
     
    12391201                if (!rays.empty()) 
    12401202                        val += sBalancedRaysFactor * fabs(sumBalancedRays) / (float)rays.size(); 
     1203 
     1204        return val; 
     1205} 
     1206 
     1207float BspTree::SplitPlaneCost(const Plane3 &candidatePlane,  
     1208                                                          const PolygonContainer &polys,                                                           
     1209                                                          const RayContainer &rays) const 
     1210{ 
     1211        float val = 0; 
     1212 
     1213        if (sSplitPlaneStrategy & VERTICAL_AXIS) 
     1214        { 
     1215                Vector3 tinyAxis(0,0,0); tinyAxis[mBox.Size().TinyAxis()] = 1.0f; 
     1216                // we put a penalty on the dot product between the "tiny" vertical axis 
     1217                // and the split plane axis 
     1218                val += sVerticalSplitsFactor *  
     1219                           fabs(DotProd(candidatePlane.mNormal, tinyAxis)); 
     1220        } 
     1221 
     1222        if ((sSplitPlaneStrategy & BALANCED_POLYS)      || 
     1223                (sSplitPlaneStrategy & LEAST_SPLITS)        || 
     1224                (sSplitPlaneStrategy & LARGEST_POLY_AREA)   || 
     1225                (sSplitPlaneStrategy & BALANCED_VIEW_CELLS) || 
     1226                (sSplitPlaneStrategy & BLOCKED_RAYS)) 
     1227        { 
     1228        val += SplitPlaneCost(candidatePlane, polys); 
     1229        } 
     1230 
     1231        if ((sSplitPlaneStrategy & BALANCED_RAYS)      || 
     1232                (sSplitPlaneStrategy & LEAST_RAY_SPLITS)) 
     1233        { 
     1234                val += SplitPlaneCost(candidatePlane, rays); 
     1235        } 
    12411236 
    12421237        // return linear combination of the sums 
     
    13701365        } 
    13711366         
    1372 //#ifdef _DEBUG 
     1367#ifdef _DEBUG 
    13731368        Debug << "BSP stats: " 
    13741369                  << "Depth: " << data.mDepth << " (max: " << sTermMaxDepth << "), " 
    13751370                  << "#polygons: " << (int)data.mPolygons->size() << " (max: " << sTermMaxPolygons << "), " 
    13761371                  << "#rays: " << (int)data.mRays->size() << " (max: " << sTermMaxRays << ")" << endl; 
    1377 //#endif 
     1372#endif 
    13781373} 
    13791374 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r332 r335  
    403403                @param polys the polygon list on which the split decition is based 
    404404                @param rays ray container on which selection may be based 
    405                 Returns the split plane 
     405                @note the polygons can be reordered in the process 
     406                @returns the split plane 
    406407        */ 
    407408        Plane3 SelectPlane(BspLeaf *leaf,  
     
    410411 
    411412        /** Evaluates the contribution of the candidate split plane. 
    412                 @note the polygons can be reordered in the process. 
     413                 
     414                @param canditatePlane the candidate split plane 
     415                @param polys the polygons the split can be based on 
     416                @param rays the rays the split can be based on 
    413417                @returns the cost of the candidate split plane 
    414418        */ 
    415         float SplitPlaneCost(PolygonContainer &polys,  
    416                                                  const Plane3 &candidatePlane, 
    417                                                  const RayContainer &rays); 
     419        float SplitPlaneCost(const Plane3 &candidatePlane, 
     420                                                 const PolygonContainer &polys,                                                   
     421                                                 const RayContainer &rays) const; 
     422 
     423        /** Strategies where the effect of the split plane is tested 
     424            on all input rays. 
     425                @returns the cost of the candidate split plane 
     426        */ 
     427        float SplitPlaneCost(const Plane3 &candidatePlane, 
     428                                                 const PolygonContainer &polys) const; 
     429 
     430        /** Strategies where the effect of the split plane is tested 
     431            on all input polygons. 
     432                @returns the cost of the candidate split plane 
     433        */ 
     434        float SplitPlaneCost(const Plane3 &candidatePlane, 
     435                                                 const RayContainer &polys) const; 
    418436 
    419437        /** Filters next view cell down the tree and inserts it into the appropriate leaves 
  • trunk/VUT/GtpVisibilityPreprocessor/src/default.env

    r333 r335  
    99#       filename vienna.x3d 
    1010#       filename ../data/vienna/vienna-simple.x3d 
    11 #       filename ../data/vienna/vienna-buildings.x3d 
     11        filename ../data/vienna/vienna-buildings.x3d 
    1212#       filename ../data/vienna/viewcells-25-sel.x3d 
    13         filename ../data/atlanta/atlanta2.x3d 
     13#       filename ../data/atlanta/atlanta2.x3d 
    1414#       filename ../data/soda/soda.dat 
    1515#       filename ../data/soda/soda5.dat 
     
    3030        sahUseFaces true 
    3131        Termination { 
    32                 minCost 1 
     32                minCost 2 
    3333                maxDepth 18 
    34                 maxCostRatio 0.95 
     34                maxCostRatio 0.9 
    3535                ct_div_ci 0.5 
    3636        } 
     
    4343MeshKdTree { 
    4444        Termination { 
    45                 minCost 1 
    46                 maxDepth 12 
    47                 maxCostRatio 0.95 
     45                minCost 4 
     46                maxDepth 18 
     47                maxCostRatio 0.9 
    4848                ct_div_ci 0.5 
    4949        } 
     
    5656 
    5757Sampling { 
    58         totalSamples    100 
     58        totalSamples    1000000 
    5959        samplesPerPass  20 
    6060} 
    6161 
    6262ViewCells { 
    63         hierarchyType bspTree 
     63        #hierarchy kdTree 
     64        hierarchy bspTree 
     65        # hierarchy sceneDependent 
     66         
    6467        height 5.0 
    6568        maxViewCells 0 
    66         #hierarchyType kdTree 
    67         #hierarchyType sceneDependent 
     69         
    6870#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
    69 #       filename ../data/vienna/viewcells-25-sel.x3d 
    70         filename ../data/vienna/viewcells-25.x3d 
     71        filename ../data/vienna/viewcells-25-sel.x3d 
     72#       filename ../data/vienna/viewcells-25.x3d 
    7173#       filename ../data/vienna/viewcells-large-sel.x3d 
    7274} 
    7375 
    7476BspTree { 
    75 #       constructionMethod fromRays 
    76 #       constructionMethod fromViewCells 
    77         constructionMethod fromSceneGeometry 
     77        Construction { 
     78        #       input fromRays 
     79        #       input fromViewCells 
     80                input fromSceneGeometry 
     81                samples 200000 
     82                sideTolerance 0.002 
     83        } 
     84 
    7885 
    7986        # random polygon       = 1 
     
    8592        # vertical axis        = 64 
    8693        # blocked rays         = 128 
    87          
     94        # least ray splits     = 256 
     95        # balanced rays        = 512 
     96 
    8897        # least splits + balanced polygons 
    8998        #splitPlaneStrategy 12 
     
    101110        #splitPlaneStrategy 72 
    102111         
     112        # axis aligned + blocked rays 
     113        #splitPlaneStrategy 130 
     114         
    103115        splitPlaneStrategy 66 
    104116         
     
    106118         
    107119        Termination { 
    108                 maxPolysForAxisAligned 100 
     120                # autopartition 
     121                maxRays -1 
    109122                maxPolygons 20 
    110123                maxDepth 100 
     124                 
     125                #axis aligned split 
     126                maxPolysForAxisAligned 100 
     127                maxCostRatio 0.9 
     128                ct_div_ci 0.5 
    111129        } 
     130         
     131        #axis aligned split 
     132        splitBorder 0.01 
     133         
    112134        # if split polys are stored for visualization 
    113135        storeSplitPolys false 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r333 r335  
    9696   
    9797    
    98   if (0) { 
     98  if (1) { 
    9999    p->ComputeVisibility(); 
    100100    p->ExportPreprocessedData("scene.vis"); 
Note: See TracChangeset for help on using the changeset viewer.