Changeset 374
- Timestamp:
- 11/01/06 11:36:11 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.inl
r372 r374 104 104 // cbb is the percent of the screen real estate this would cover 105 105 Real32 cbb = (max[0] - min[0]) * (max[1] - min[1]) / 4.f; 106 //Real32 pix = cbb * vp->getPixelWidth() * vp->getPixelHeight();107 106 108 #if 1 109 //THIS IS WHAT I WANT TO DO....but the calls to validate never return 110 //commitChanges(); 107 //Get max LOD number of triangles 111 108 NodePtr pmax = action->getNode(0); 112 109 GeoStatsAttachmentPtr st_max = GeoStatsAttachment::get(pmax); 110 if(st_max == NullFC) 111 { 112 GeoStatsAttachment::addTo(pmax); 113 st_max = GeoStatsAttachment::get(pmax); 114 } 113 115 st_max->validate(); 114 116 117 //Get min LOD number of triangles 115 118 NodePtr pmin = action->getNode(numLevels-1); 116 119 GeoStatsAttachmentPtr st_min = GeoStatsAttachment::get(pmin); 120 if(st_min == NullFC) 121 { 122 GeoStatsAttachment::addTo(pmin); 123 st_min = GeoStatsAttachment::get(pmin); 124 } 117 125 st_min->validate(); 118 126 119 Real32 deg_percent = (st_min->getTriangles() / st_max->getTriangles()) * numLevels; 127 // Find out what the average degradation of triangles is each level 128 Real32 deg_percent = (st_min->getTriangles() / st_max->getTriangles()) * (numLevels-1); 120 129 if(deg_percent >= 1.0) 121 130 { 122 std::cout << "LOD's not in decreasing complexity!" << std::endl; 123 deg_percent = 0.5; 131 deg_percent = 0.9; 124 132 } 125 133 126 Real32 base_percent = 0.1; //Above this renders at full res! this should be tweakable134 Real32 base_percent = ra->getScreenLODCoverageThreshold(); //Above this renders at full res! 127 135 136 // While the screen percentage of the object is less that the percent allowed for the current LOD 137 // move down a LOD and find out the new allowed percentage 128 138 while(cbb < base_percent) 129 139 { … … 133 143 break; 134 144 } 135 #else136 Real32 degradation_base = ra->getScreenLODCoverageThreshold();137 while(cbb < degradation_base)138 {139 degradation_base*=0.3;140 index++;141 if (index >= numLevels)142 {143 index=numLevels-1;144 break;145 }146 }147 #endif148 145 } 149 146 }
