Changeset 10084
- Timestamp:
- 04/23/09 12:24:27 (4 years ago)
- Location:
- OpenSceneGraph/trunk/src/osgPlugins/OpenFlight
- Files:
-
- 3 modified
-
Document.cpp (modified) (2 diffs)
-
Document.h (modified) (4 diffs)
-
GeometryRecords.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/Document.cpp
r8563 r10084 46 46 _shaderPoolParent(false) 47 47 { 48 _subsurfaceDepth = new osg::Depth(osg::Depth::LESS, 0.0, 1.0,false); 48 49 } 49 50 … … 111 112 } 112 113 114 void Document::setSubSurfacePolygonOffset(int level, osg::PolygonOffset* po) 115 { 116 _subsurfacePolygonOffsets[level] = po; 117 } 118 119 osg::PolygonOffset* Document::getSubSurfacePolygonOffset(int level) 120 { 121 osg::notify(osg::DEBUG_INFO)<<"Document::getSubSurfacePolygonOffset("<<level<<")"<<std::endl; 122 osg::ref_ptr<osg::PolygonOffset>& po = _subsurfacePolygonOffsets[level]; 123 if (!po) 124 { 125 po = new osg::PolygonOffset(-1.0f*float(level), -1.0f); 126 } 127 return po.get(); 128 } 129 113 130 double flt::unitsToMeters(CoordUnits unit) 114 131 { -
OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/Document.h
r8563 r10084 25 25 #include <osg/Transform> 26 26 #include <osg/Geometry> 27 #include <osg/PolygonOffset> 28 #include <osg/Depth> 27 29 #include <osgDB/ReaderWriter> 28 30 … … 166 168 ShaderPool* getOrCreateShaderPool(); 167 169 bool getShaderPoolParent() const { return _shaderPoolParent; } 170 171 void setSubSurfacePolygonOffset(int level, osg::PolygonOffset* po); 172 osg::PolygonOffset* getSubSurfacePolygonOffset(int level); 173 174 void setSubSurfaceDepth(osg::Depth* depth) { _subsurfaceDepth = depth; } 175 osg::Depth* getSubSurfaceDepth() { return _subsurfaceDepth.get(); } 168 176 169 177 … … 185 193 void setDesiredUnits(CoordUnits units ) { _desiredUnits=units; } 186 194 CoordUnits getDesiredUnits() const { return _desiredUnits; } 187 195 188 196 void setKeepExternalReferences( bool flag) { _keepExternalReferences=flag; } 189 197 bool getKeepExternalReferences() const { return _keepExternalReferences; } … … 226 234 osg::ref_ptr<LightPointAnimationPool> _lightPointAnimationPool; 227 235 osg::ref_ptr<ShaderPool> _shaderPool; 236 237 typedef std::map<int, osg::ref_ptr<osg::PolygonOffset> > SubSurfacePolygonOffsets; 238 SubSurfacePolygonOffsets _subsurfacePolygonOffsets; 239 osg::ref_ptr<osg::Depth> _subsurfaceDepth; 240 228 241 bool _colorPoolParent; 229 242 bool _texturePoolParent; -
OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/GeometryRecords.cpp
r9041 r10084 24 24 #include <osg/Texture2D> 25 25 #include <osg/CullFace> 26 #include <osg/PolygonOffset>27 #include <osg/Depth>28 26 #include <osg/BlendFunc> 29 27 #include <osgUtil/TransformAttributeFunctor> … … 384 382 if (document.subfaceLevel() > 0) 385 383 { 386 static osg::ref_ptr<osg::PolygonOffset> polygonOffset = new osg::PolygonOffset(-10.0f, -40.0f); 387 stateset->setAttributeAndModes(polygonOffset.get(), osg::StateAttribute::ON); 388 389 static osg::ref_ptr<osg::Depth> depth = new osg::Depth(osg::Depth::LESS, 0.0, 1.0,false); 390 stateset->setAttribute(depth.get()); 384 stateset->setAttributeAndModes(document.getSubSurfacePolygonOffset(document.subfaceLevel()), osg::StateAttribute::ON); 385 stateset->setAttribute(document.getSubSurfaceDepth()); 391 386 392 387 stateset->setRenderBinDetails(document.subfaceLevel(),"RenderBin"); 393 388 } 394 395 #if 0396 // note from Robert Osfield, this "optimization" breaks multi-textured datasets that mix single texture397 // and mulit-texture geometries as the Multitexture parsing can come after the below code, and accidentally398 // polute the non multi-texture geometries StateSet.399 400 // A simple share stateset optimization.401 static osg::ref_ptr<osg::StateSet> lastStateset;402 if (lastStateset.valid() && (stateset->compare(*lastStateset,false)==0))403 stateset = lastStateset;404 else405 lastStateset = stateset;406 #endif407 389 408 390 _geode->setStateSet(stateset.get()); … … 953 935 if (document.subfaceLevel() > 0) 954 936 { 955 static osg::ref_ptr<osg::PolygonOffset> polygonOffset = new osg::PolygonOffset(-10.0f, -40.0f); 956 stateset->setAttributeAndModes(polygonOffset.get(), osg::StateAttribute::ON); 957 958 static osg::ref_ptr<osg::Depth> depth = new osg::Depth(osg::Depth::LESS, 0.0, 1.0,false); 959 stateset->setAttribute(depth.get()); 937 stateset->setAttributeAndModes(document.getSubSurfacePolygonOffset(document.subfaceLevel()), osg::StateAttribute::ON); 938 stateset->setAttribute(document.getSubSurfaceDepth()); 960 939 961 940 stateset->setRenderBinDetails(document.subfaceLevel(),"RenderBin"); 962 941 } 963 964 #if 0965 // note from Robert Osfield, this "optimization" breaks multi-textured datasets that mix single texture966 // and mulit-texture geometries as the Multitexture parsing can come after the below code, and accidentally967 // polute the non multi-texture geometries StateSet.968 969 // A simple share stateset optimization.970 static osg::ref_ptr<osg::StateSet> lastStateset;971 if (lastStateset.valid() && (stateset->compare(*lastStateset,false)==0))972 stateset = lastStateset;973 else974 lastStateset = stateset;975 #endif976 942 977 943 _geode->setStateSet(stateset.get());
