-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
124 changed files
with
26,465 additions
and
149 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from http://code.google.com/p/osgworks/ |
118 changes: 118 additions & 0 deletions
118
src/osg3DViewer/3rdparty/osgWorks/osgwTools/CountStateSets.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/*************** <auto-copyright.pl BEGIN do not edit this line> ************** | ||
* | ||
* osgWorks is (C) Copyright 2009-2011 by Kenneth Mark Bryden | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1 as published by the Free Software Foundation. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
* | ||
*************** <auto-copyright.pl END do not edit this line> ***************/ | ||
|
||
#include "osgwTools/CountStateSets.h" | ||
#include <osgwTools/StateSetUtils.h> | ||
#include <osg/NodeVisitor> | ||
#include <osg/Geode> | ||
#include <osg/Drawable> | ||
#include <osg/StateSet> | ||
#include <osg/StateAttribute> | ||
#include <osg/Notify> | ||
|
||
|
||
|
||
namespace osgwTools | ||
{ | ||
|
||
|
||
CountStateSets::CountStateSets( bool removeEmptyStateSets, const osg::NodeVisitor::TraversalMode travMode ) | ||
: osg::NodeVisitor( travMode ), | ||
_removeEmptyStateSets( removeEmptyStateSets ), | ||
_uniqueStateSets( 0 ), | ||
_sharedStateSets( 0 ), | ||
_emptyStateSets( 0 ), | ||
_removedStateSets( 0 ) | ||
{ | ||
} | ||
CountStateSets::~CountStateSets() | ||
{ | ||
} | ||
|
||
void | ||
CountStateSets::reset() | ||
{ | ||
_uniqueStateSets = 0; | ||
_sharedStateSets = 0; | ||
_emptyStateSets = 0; | ||
_removedStateSets = 0; | ||
} | ||
|
||
void | ||
CountStateSets::setRemoveEmptyStateSets( bool removeEmptyStateSets ) | ||
{ | ||
_removeEmptyStateSets = removeEmptyStateSets; | ||
} | ||
|
||
|
||
void | ||
CountStateSets::apply( osg::Node& node ) | ||
{ | ||
if( !processStateSet( node.getStateSet() ) && _removeEmptyStateSets ) | ||
{ | ||
node.setStateSet( NULL ); | ||
_removedStateSets++; | ||
} | ||
traverse( node ); | ||
} | ||
void | ||
CountStateSets::apply( osg::Geode& node ) | ||
{ | ||
if( !processStateSet( node.getStateSet() ) && _removeEmptyStateSets ) | ||
{ | ||
node.setStateSet( NULL ); | ||
_removedStateSets++; | ||
} | ||
|
||
unsigned int idx; | ||
for( idx=0; idx<node.getNumDrawables(); idx++ ) | ||
{ | ||
osg::Drawable* draw = node.getDrawable( idx ); | ||
if( !processStateSet( draw->getStateSet() ) && _removeEmptyStateSets ) | ||
{ | ||
draw->setStateSet( NULL ); | ||
_removedStateSets++; | ||
} | ||
} | ||
|
||
traverse( node ); | ||
} | ||
|
||
bool | ||
CountStateSets::processStateSet( osg::StateSet* ss ) | ||
{ | ||
if( ss == NULL ) | ||
return( true ); | ||
|
||
if( ss->referenceCount() == 1 ) | ||
_uniqueStateSets++; | ||
else | ||
_sharedStateSets++; | ||
|
||
bool empty = osgwTools::isEmpty( *ss ); | ||
if( empty ) | ||
_emptyStateSets++; | ||
return( !empty ); | ||
} | ||
|
||
|
||
|
||
// osgwTools | ||
} |
84 changes: 84 additions & 0 deletions
84
src/osg3DViewer/3rdparty/osgWorks/osgwTools/CountStateSets.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/*************** <auto-copyright.pl BEGIN do not edit this line> ************** | ||
* | ||
* osgWorks is (C) Copyright 2009-2011 by Kenneth Mark Bryden | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License version 2.1 as published by the Free Software Foundation. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
* | ||
*************** <auto-copyright.pl END do not edit this line> ***************/ | ||
|
||
#ifndef __OSGWTOOLS_COUNT_STATE_SETS_H__ | ||
#define __OSGWTOOLS_COUNT_STATE_SETS_H__ 1 | ||
|
||
|
||
//#include "osgwTools/Export.h" | ||
#include <osg/NodeVisitor> | ||
|
||
#include <string> | ||
|
||
#define OSGWTOOLS_EXPORT | ||
|
||
namespace osgwTools | ||
{ | ||
|
||
|
||
/** \class CountStateSets CountStateSets.h <osgwTools/CountStateSets.h> | ||
\brief Visitor to count \c StateSet objects and optionally removes empty \c StateSet objects. | ||
\deprecated Please use CountsVisitor and RemoveData instead. | ||
*/ | ||
// | ||
class OSGWTOOLS_EXPORT CountStateSets : public osg::NodeVisitor | ||
{ | ||
public: | ||
/** | ||
@param removeEmptyStateSets The default is true. | ||
@param travMode The traversal mode. The default is \c osg::NodeVisitor::TRAVERSE_ALL_CHILDREN. | ||
*/ | ||
CountStateSets( bool removeEmptyStateSets=true, const osg::NodeVisitor::TraversalMode travMode=osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ); | ||
~CountStateSets(); | ||
|
||
/** Sets internal counts to zero. */ | ||
void reset(); | ||
|
||
/** Overrides for base class \c apply() method. */ | ||
virtual void apply( osg::Node& node ); | ||
/** Overrides for base class \c apply() method. */ | ||
virtual void apply( osg::Geode& node ); | ||
|
||
/** Specifies whether to remove empty \c StateSet objects. The default is true | ||
(remove empty \c StateSet objects).*/ | ||
void setRemoveEmptyStateSets( bool removeEmptyStateSets ); | ||
|
||
/** During traversal, these counters track the total number of programs | ||
and the NodeVisitor removes the uniforms. They are public, so the calling code can access | ||
them directly following the traversal. */ | ||
unsigned int _uniqueStateSets, _sharedStateSets, _emptyStateSets, _removedStateSets; | ||
|
||
protected: | ||
/** This function examines the \c StateSet and increments the unique and shared counters. It also | ||
increments the empty counter, but doesn't remove it or increment the removed counter. | ||
The calling \c apply() method takes care of this based on the return | ||
value. It returns true if the \c StateSet is NULL or not empty and returns false if the | ||
\c StateSet is non-NULL and empty. */ | ||
bool processStateSet( osg::StateSet* ss ); | ||
|
||
bool _removeEmptyStateSets; | ||
}; | ||
|
||
|
||
// osgwTools | ||
} | ||
|
||
// __OSGWTOOLS_COUNT_STATE_SETS_H__ | ||
#endif |
Oops, something went wrong.