Changeset 359

Show
Ignore:
Timestamp:
10/22/06 19:00:49 (2 years ago)
Author:
dshipton
Message:

Added a mode that looks at triangle degradation….but it can't seem to get triangle counts back….
maybe dirk can spot the problem…

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.cpp

    r325 r359  
    4545 
    4646#include <OSGConfig.h> 
    47 #include <OSGCamera.h> 
    4847#include <OSGRenderTraversalAction.h> 
    4948 
  • branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.h

    r325 r359  
    4848#include "OSGViewport.h" 
    4949#include "OSGDrawActionBase.h" 
     50#include "OSGGeoStatsAttachment.h" 
    5051 
    5152OSG_BEGIN_NAMESPACE 
  • branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGScreenLOD.inl

    r355 r359  
    101101        // cbb is the percent of the screen real estate this would cover 
    102102        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(); 
    104104 
    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; 
    107127            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; 
    109137            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        } 
    126144    } 
    127145