|
Revision 13041, 2.4 kB
(checked in by robert, 15 months ago)
|
|
Ran script to remove trailing spaces and tabs
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #if defined(_MSC_VER) |
|---|
| 14 | #pragma warning( disable : 4786 ) |
|---|
| 15 | #endif |
|---|
| 16 | |
|---|
| 17 | #include <stdio.h> |
|---|
| 18 | #include <string.h> |
|---|
| 19 | #include <list> |
|---|
| 20 | #include <set> |
|---|
| 21 | |
|---|
| 22 | #include <osgUtil/DisplayRequirementsVisitor> |
|---|
| 23 | |
|---|
| 24 | using namespace osg; |
|---|
| 25 | using namespace osgUtil; |
|---|
| 26 | |
|---|
| 27 | DisplayRequirementsVisitor::DisplayRequirementsVisitor() |
|---|
| 28 | { |
|---|
| 29 | setTraversalMode(NodeVisitor::TRAVERSE_ALL_CHILDREN); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | void DisplayRequirementsVisitor::applyStateSet(StateSet& stateset) |
|---|
| 33 | { |
|---|
| 34 | if (!_ds) _ds = new osg::DisplaySettings; |
|---|
| 35 | |
|---|
| 36 | unsigned int min = 0; |
|---|
| 37 | |
|---|
| 38 | if (stateset.getMode(GL_STENCIL_TEST) & StateAttribute::ON) |
|---|
| 39 | { |
|---|
| 40 | min = 1; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | if (stateset.getAttribute(StateAttribute::STENCIL)) |
|---|
| 44 | { |
|---|
| 45 | min = 1; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | if (min>_ds->getMinimumNumStencilBits()) |
|---|
| 49 | { |
|---|
| 50 | |
|---|
| 51 | _ds->setMinimumNumStencilBits(min); |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | void DisplayRequirementsVisitor::apply(Node& node) |
|---|
| 56 | { |
|---|
| 57 | osg::StateSet* stateset = node.getStateSet(); |
|---|
| 58 | if (stateset) applyStateSet(*stateset); |
|---|
| 59 | |
|---|
| 60 | if (strcmp(node.className(),"Impostor")==0) |
|---|
| 61 | { |
|---|
| 62 | if (!_ds) _ds = new osg::DisplaySettings; |
|---|
| 63 | |
|---|
| 64 | unsigned int min = 1; |
|---|
| 65 | if (min>_ds->getMinimumNumAlphaBits()) |
|---|
| 66 | { |
|---|
| 67 | |
|---|
| 68 | _ds->setMinimumNumAlphaBits(min); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | traverse(node); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | void DisplayRequirementsVisitor::apply(Geode& geode) |
|---|
| 76 | { |
|---|
| 77 | osg::StateSet* geode_stateset = geode.getStateSet(); |
|---|
| 78 | if (geode_stateset) applyStateSet(*geode_stateset); |
|---|
| 79 | |
|---|
| 80 | for(unsigned int i = 0; i < geode.getNumDrawables(); i++ ) |
|---|
| 81 | { |
|---|
| 82 | osg::StateSet* stateset = geode.getDrawable(i)->getStateSet(); |
|---|
| 83 | if (stateset) applyStateSet(*stateset); |
|---|
| 84 | } |
|---|
| 85 | } |
|---|