Ignore:
Timestamp:
03/05/07 11:07:44 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2183 r2187  
    3232namespace GtpVisibilityPreprocessor { 
    3333 
    34   const static bool ADDITIONAL_GEOMETRY_HACK = false; 
    35  
    36   Preprocessor *preprocessor = NULL; 
    37    
    38 // HACK: Artificially modify scene to watch rendercost changes 
    39 static void AddGeometry(SceneGraph *scene) 
    40 { 
    41         scene->GetRoot()->UpdateBox(); 
    42  
    43         AxisAlignedBox3 sceneBox = scene->GetBox(); 
    44  
    45         int n = 200; 
    46  
    47         if (0) 
    48         { 
    49                 // form grid of boxes 
    50                 for (int i = 0; i < n; ++ i) 
    51                 { 
    52                         for (int j = 0; j < n; ++ j) 
    53                         { 
    54                                 const Vector3 scale2((float)j * 0.8f / n + 0.1f,  0.05f, (float)i * 0.8f  / (float)n + 0.1f); 
    55  
    56                                 const Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
    57  
    58                                 const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
    59                                 AxisAlignedBox3 box(pt2, pt2 + boxSize); 
    60                                 Mesh *mesh = CreateMeshFromBox(box); 
    61  
    62                                 mesh->Preprocess(); 
    63  
    64                                 MeshInstance *mi = new MeshInstance(mesh); 
    65                                 scene->GetRoot()->mGeometry.push_back(mi); 
    66                         } 
    67                 } 
    68  
    69                 for (int i = 0; i < n; ++ i) 
    70                 { 
    71                         for (int j = 0; j < n; ++ j) 
    72                         { 
    73                                 const Vector3 scale2(0.15f, (float)j * 0.8f / n + 0.1f, (float)i * 0.8f  / (float)n + 0.1f); 
    74  
    75                                 Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
    76  
    77                                 Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
    78                                 AxisAlignedBox3 box(pt2, pt2 + boxSize); 
    79                                 Mesh *mesh = CreateMeshFromBox(box); 
    80  
    81                                 mesh->Preprocess(); 
    82  
    83                                 MeshInstance *mi = new MeshInstance(mesh); 
    84                                 scene->GetRoot()->mGeometry.push_back(mi); 
    85                         } 
    86                 } 
    87  
    88                 for (int i = 0; i < n; ++ i) 
    89                 { 
    90                         const Vector3 scale2(2, 0.2f, (float)i * 0.8f  / (float)n + 0.1f); 
    91  
    92                         Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
    93                         Vector3 boxSize = sceneBox.Size() * Vector3(0.005f, 0.02f, 0.005f); 
    94  
    95                         AxisAlignedBox3 box(pt2 + 0.1f, pt2 + boxSize); 
    96                         Mesh *mesh = CreateMeshFromBox(box); 
    97  
    98                         mesh->Preprocess(); 
    99  
    100                         MeshInstance *mi = new MeshInstance(mesh); 
    101                         scene->GetRoot()->mGeometry.push_back(mi); 
    102                 } 
    103  
    104                 scene->GetRoot()->UpdateBox(); 
    105         } 
    106  
    107         if (1) 
    108         { 
    109                 // plane separating view space regions 
    110                 const Vector3 scale(1.0f, 0.0, 0); 
    111  
    112                 Vector3 pt = sceneBox.Min() + scale * (sceneBox.Max() - sceneBox.Min()); 
    113  
    114                 Plane3 cuttingPlane(Vector3(1, 0, 0), pt); 
    115                 Mesh *planeMesh = new Mesh(); 
    116  
    117                 Polygon3 *poly = sceneBox.CrossSection(cuttingPlane); 
    118                 IncludePolyInMesh(*poly, *planeMesh); 
    119  
    120                 planeMesh->Preprocess(); 
    121  
    122                 MeshInstance *planeMi = new MeshInstance(planeMesh); 
    123                 scene->GetRoot()->mGeometry.push_back(planeMi); 
    124         }        
    125 } 
    126  
     34 
     35Preprocessor *preprocessor = NULL; 
     36   
    12737 
    12838Preprocessor::Preprocessor(): 
     
    599509        if (result)  
    600510        {  
    601           // HACK  
    602                 if (ADDITIONAL_GEOMETRY_HACK) 
    603                         AddGeometry(mSceneGraph); 
    604511 
    605512                mSceneGraph->AssignObjectIds(); 
     
    12281135        Environment::GetSingleton()->GetBoolValue("ViewCells.loadFromFile", loadViewCells); 
    12291136 
    1230         int reserveRays; 
     1137        int reserveRays;         
     1138        int constructionSamples; 
    12311139 
    12321140        if (!loadViewCells) 
    12331141        { 
    1234                 cout << "setting ray pool size to view cell construction ize" << endl; 
     1142                cout << "hack: setting ray pool size to view cell construction or evaluation size" << endl; 
     1143 
     1144                constructionSamples = 1000000; 
    12351145 
    12361146                char buf[100]; 
    12371147                Environment::GetSingleton()->GetStringValue("ViewCells.type", buf);      
    1238                  
     1148 
    12391149                if (strcmp(buf, "vspBspTree") == 0) 
    12401150                { 
    1241                         Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", reserveRays); 
    1242                         reserveRays *= 2; 
     1151                        Environment::GetSingleton()->GetIntValue("VspBspTree.Construction.samples", constructionSamples); 
     1152                         
    12431153                } 
    12441154                else if (strcmp(buf, "vspOspTree") == 0) 
    12451155                { 
    1246                         Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", reserveRays); 
    1247                         reserveRays *= 2;                        
    1248                 } 
     1156                        Environment::GetSingleton()->GetIntValue("Hierarchy.Construction.samples", constructionSamples);                 
     1157                } 
     1158 
     1159                int evalSamplesPerPass; 
     1160 
     1161                Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", evalSamplesPerPass); 
     1162 
     1163                reserveRays = max(constructionSamples, evalSamplesPerPass); 
     1164                reserveRays *= 2; 
    12491165        } 
    12501166        else 
    12511167        { 
    1252                 cout << "setting ray pool size to samples per pass" << endl; 
    1253          
     1168                cout << "setting ray pool size to samples per pass" << endl;        
    12541169                reserveRays = mSamplesPerPass * 2; 
    12551170        } 
     
    12741189        const long t1 = GetTime(); 
    12751190         
    1276         if ((int)rays.size() > 10000) { 
     1191        if (1 && (rays.size() > 10000)) 
     1192        { 
    12771193         
    12781194                mRayCaster->SortRays(rays); 
     
    12981214 
    12991215        if (mUseHwGlobalLines)  
     1216        { 
    13001217          CastRaysWithHwGlobalLines( 
    13011218                                                                rays, 
     
    13041221                                                                pruneInvalidRays 
    13051222                                                                ); 
     1223        } 
    13061224        else 
     1225        { 
    13071226          mRayCaster->CastRays( 
    13081227                                                 rays,                           
     
    13111230                                                 castDoubleRays, 
    13121231                                                 pruneInvalidRays); 
    1313    
    1314         if ((int)rays.size() > 10000)  
     1232        } 
     1233 
     1234        if (rays.size() > 10000)  
    13151235        { 
    13161236                cout << endl; 
     
    13281248} 
    13291249 
    1330  
    13311250   
    13321251void 
    13331252Preprocessor::CastRaysWithHwGlobalLines( 
    13341253                                                                                SimpleRayContainer &rays, 
    1335                                                                           VssRayContainer &vssRays, 
    1336                                                                           const bool castDoubleRays, 
    1337                                                                           const bool pruneInvalidRays 
    1338                                                                           ) 
     1254                                                                                VssRayContainer &vssRays, 
     1255                                                                                const bool castDoubleRays, 
     1256                                                                                const bool pruneInvalidRays) 
    13391257{ 
    13401258  SimpleRayContainer::const_iterator rit, rit_end = rays.end(); 
     
    13521270                } 
    13531271#endif 
    1354           rayBucket.push_back(ray); 
    1355            
    1356           // 16 rays gathered => do ray casting 
    1357           if ((int)rayBucket.size() >= 16) 
    1358                 { 
    1359                   mRayCaster->CastRays16( 
    1360                                                                  rayBucket,                              
    1361                                                                  vssRays, 
    1362                                                                  mViewCellsManager->GetViewSpaceBox(), 
    1363                                                                  castDoubleRays, 
    1364                                                                  pruneInvalidRays); 
    1365                    
    1366                   rayBucket.clear(); 
    1367                 } 
    1368          
    1369                 if ((int)rays.size() > 100000 && i % 100000 == 0) 
     1272                rayBucket.push_back(ray); 
     1273 
     1274                // 16 rays gathered => do ray casting 
     1275                if (rayBucket.size() >= 16) 
     1276                { 
     1277                        mRayCaster->CastRays16( 
     1278                                rayBucket,                               
     1279                                vssRays, 
     1280                                mViewCellsManager->GetViewSpaceBox(), 
     1281                                castDoubleRays, 
     1282                                pruneInvalidRays); 
     1283 
     1284                        rayBucket.clear(); 
     1285                } 
     1286 
     1287                if (rays.size() > 100000 && i % 100000 == 0) 
    13701288                        cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 
    13711289        } 
Note: See TracChangeset for help on using the changeset viewer.