Changeset 359
- Timestamp:
- 10/22/06 19:00:49 (2 years ago)
- Files:
-
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.cpp (modified) (1 diff)
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.h (modified) (1 diff)
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.inl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.cpp
r325 r359 45 45 46 46 #include <OSGConfig.h> 47 #include <OSGCamera.h>48 47 #include <OSGRenderTraversalAction.h> 49 48 branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.h
r325 r359 48 48 #include "OSGViewport.h" 49 49 #include "OSGDrawActionBase.h" 50 #include "OSGGeoStatsAttachment.h" 50 51 51 52 OSG_BEGIN_NAMESPACE branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.inl
r355 r359 101 101 // cbb is the percent of the screen real estate this would cover 102 102 Real32 cbb = (max[0] - min[0]) * (max[1] - min[1]) / 4.f; 103 Real32 pix = cbb * vp->getPixelWidth() * vp->getPixelHeight();103 //Real32 pix = cbb * vp->getPixelWidth() * vp->getPixelHeight(); 104 104 105 //Make a choice based on pixels 106 if(pix < 1000) 105 #if 0 106 //THIS IS WHAT I WANT TO DO....but the calls to validate never return 107 Geometry* pmin = dynamic_cast<Geometry *>(getCPtr(action->getNode(0))); 108 Geometry* pmax = dynamic_cast<Geometry *>(getCPtr(action->getNode(numLevels-1))); 109 GeoStatsAttachmentPtr st_max = GeoStatsAttachment::get(pmin); 110 st_max->validate(); 111 112 GeoStatsAttachmentPtr st_min = GeoStatsAttachment::get(pmax); 113 st_min->validate(); 114 115 Real32 deg_percent = (st_min->getTriangles() / st_max->getTriangles()) * numLevels; 116 if(deg_percent >= 1.0) 117 { 118 std::cout << "LOD's not in decreasing complexity!" << std::endl; 119 deg_percent = 0.5; 120 } 121 122 Real32 base_percent = 0.1; //Above this renders at full res! this should be tweakable 123 124 while(cbb < base_percent) 125 { 126 base_percent*=deg_percent; 107 127 index++; 108 if(pix < 500) 128 if(index >= numLevels) 129 break; 130 } 131 #endif 132 133 Real32 degradation_base = 0.05; 134 while(cbb < degradation_base) 135 { 136 degradation_base*=0.3; 109 137 index++; 110 if(pix < 200) 111 index++; 112 if(pix < 100) 113 index++; 114 if(pix < 50) 115 index++; 116 if(pix < 5) 117 index++; 118 if(pix < 3) 119 index++; 120 if(pix < 2) 121 index++; 122 123 if (index >= numLevels) 124 index=numLevels-1; 125 138 if (index >= numLevels) 139 { 140 index=numLevels-1; 141 break; 142 } 143 } 126 144 } 127 145
