Reorganised the Group::removeChild and Geode::removeDrawable methods so
that removeChild(Node*), removeChild(uint) and equivilant Geode methods are now inline methods, not designed to be overriden, and seperated out the multiple remove method to be called removeChildren(uint, uint) which is now the only virtual method. There removeChildren is now the method to override in subclasses. This reorganisation requires some call code to be rename removeChild usage to removeChildren.
This commit is contained in:
parent
34cdf22794
commit
43f0efd6d2
@ -361,6 +361,7 @@ endif
|
||||
# DEF += `getconf LFS_CFLAGS`
|
||||
|
||||
LIBS = -lstdc++
|
||||
# DEF += -W -Wall -fPIC -pipe -Woverloaded-virtual
|
||||
DEF += -W -Wall -fPIC -pipe
|
||||
OPTF = -O2
|
||||
DBGF = -g -gstabs+ -DOSG_COMPILE_UNIT_TESTS
|
||||
|
@ -156,20 +156,16 @@ bool CURRENT_CLASS::insertChild(unsigned int index, osg::Node *child)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CURRENT_CLASS::removeChild(osg::Node *child)
|
||||
{
|
||||
return Group::removeChild(child);
|
||||
}
|
||||
|
||||
bool CURRENT_CLASS::removeChild(unsigned int pos, unsigned int numRemove)
|
||||
bool CURRENT_CLASS::removeChildren(unsigned int pos, unsigned int numRemove)
|
||||
{
|
||||
if(!Group::removeChild(pos, numRemove)) return false; // Remove child
|
||||
if(!Group::removeChildren(pos, numRemove)) return false; // Remove child
|
||||
|
||||
// Remove child from each CameraNode
|
||||
unsigned int totalCameras = _cameraList.size();
|
||||
for(unsigned int i = 0; i < totalCameras; i++)
|
||||
{
|
||||
_cameraList[i]->removeChild(pos, numRemove);
|
||||
_cameraList[i]->removeChildren(pos, numRemove);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -52,8 +52,7 @@ class CURRENT_CLASS : public osg::Group
|
||||
of added or removed children. */
|
||||
virtual bool addChild(osg::Node *child);
|
||||
virtual bool insertChild(unsigned int index, osg::Node *child);
|
||||
virtual bool removeChild(osg::Node *child);
|
||||
virtual bool removeChild(unsigned int pos, unsigned int numRemove = 1);
|
||||
virtual bool removeChildren(unsigned int pos, unsigned int numRemove = 1);
|
||||
virtual bool setChild(unsigned int i, osg::Node *node);
|
||||
|
||||
protected:
|
||||
|
@ -24,7 +24,7 @@ void Frame::rebuild()
|
||||
{
|
||||
float zPos = -0.1f;
|
||||
|
||||
removeDrawable(0, getNumDrawables());
|
||||
removeDrawables(0, getNumDrawables());
|
||||
addDrawable(build_quad(rect_, bgcolor_));
|
||||
addDrawable(build_quad(Rect(rect_.x0 + 4, rect_.y1 - 24, rect_.x1 - 4, rect_.y1 - 4), osg::Vec4(0, 0, 0, bgcolor_.w()), false, zPos));
|
||||
|
||||
|
@ -180,10 +180,10 @@ protected:
|
||||
effect_description += "DESCRIPTION:\n" + std::string(_effects[_selected_fx]->effectDescription());
|
||||
|
||||
if (_scene.valid() && _root.valid()) {
|
||||
_root->removeChild(0, _root->getNumChildren());
|
||||
_root->removeChildren(0, _root->getNumChildren());
|
||||
osg::ref_ptr<osgFX::Effect> effect = _effects[_selected_fx].get();
|
||||
effect->setEnabled(_fxen);
|
||||
effect->removeChild(0, effect->getNumChildren());
|
||||
effect->removeChildren(0, effect->getNumChildren());
|
||||
effect->addChild(_scene.get());
|
||||
effect->setUpDemo();
|
||||
_root->addChild(effect.get());
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/CoordinateSystemNode>
|
||||
#include <osg/Shape>
|
||||
#include <osg/PolygonMode>
|
||||
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReadFile>
|
||||
@ -312,15 +310,11 @@ int main(int argc, char **argv)
|
||||
viewer.setSceneData(root.get());
|
||||
|
||||
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(root.get());
|
||||
osg::Group * overlaySubGraph = new osg::Group;
|
||||
if (csn)
|
||||
{
|
||||
|
||||
bool insertOverlayNode = true;
|
||||
osg::ref_ptr<osgSim::OverlayNode> overlayNode;
|
||||
osg::Node* cessna = osgDB::readNodeFile("cessna.osg");
|
||||
double s = 200000.0 / cessna->getBound().radius();
|
||||
|
||||
if (insertOverlayNode)
|
||||
{
|
||||
|
||||
@ -331,34 +325,21 @@ int main(int argc, char **argv)
|
||||
{
|
||||
overlayNode->addChild( csn->getChild(i) );
|
||||
}
|
||||
csn->removeChild(0, csn->getNumChildren());
|
||||
|
||||
csn->removeChildren(0, csn->getNumChildren());
|
||||
csn->addChild(overlayNode.get());
|
||||
|
||||
osg::ref_ptr<osg::PolygonMode> polymode = new osg::PolygonMode;
|
||||
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
|
||||
osg::NodeCallback* sphereCb = new ModelPositionCallback;
|
||||
osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform;
|
||||
mt->setUpdateCallback(sphereCb);
|
||||
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||
osg::ref_ptr<osg::ShapeDrawable> sd;
|
||||
sd = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),s));
|
||||
sd->setColor(osg::Vec4(1.0,0.0,0.0,1.0));
|
||||
geode->addDrawable(sd.get());
|
||||
|
||||
mt->addChild(geode.get());
|
||||
overlaySubGraph->addChild(mt.get());
|
||||
|
||||
geode->getOrCreateStateSet()->setAttributeAndModes(polymode.get(), osg::StateAttribute::ON);
|
||||
// tell the overlay node to continously update its overlay texture
|
||||
// as we know we'll be tracking a moving target.
|
||||
overlayNode->setContinuousUpdate(true);
|
||||
}
|
||||
|
||||
|
||||
//osg::Node* cessna = osgDB::readNodeFile("f15.ive");
|
||||
osg::Node* cessna = osgDB::readNodeFile("cessna.osg");
|
||||
if (cessna)
|
||||
{
|
||||
double s = 200000.0 / cessna->getBound().radius();
|
||||
|
||||
osg::MatrixTransform* scaler = new osg::MatrixTransform;
|
||||
scaler->addChild(cessna);
|
||||
scaler->setMatrix(osg::Matrixd::scale(s,s,s)*osg::Matrixd::rotate(rotation));
|
||||
@ -367,15 +348,18 @@ int main(int argc, char **argv)
|
||||
osg::MatrixTransform* mt = new osg::MatrixTransform;
|
||||
mt->addChild(scaler);
|
||||
|
||||
|
||||
if (!nc) nc = new ModelPositionCallback;
|
||||
|
||||
mt->setUpdateCallback(nc);
|
||||
|
||||
csn->addChild(mt);
|
||||
|
||||
// if (overlaySubGraph) overlaySubGraph->addChild(mt);
|
||||
|
||||
// if we are using an overaly node, use the cessna subgraph as the overlay subgraph
|
||||
if (overlayNode.valid())
|
||||
{
|
||||
overlayNode->setOverlaySubgraph(mt);
|
||||
}
|
||||
|
||||
osgGA::NodeTrackerManipulator* tm = new osgGA::NodeTrackerManipulator;
|
||||
tm->setTrackerMode(trackerMode);
|
||||
@ -390,10 +374,6 @@ int main(int argc, char **argv)
|
||||
std::cout<<"Failed to read cessna.osg"<<std::endl;
|
||||
}
|
||||
|
||||
if (overlayNode.valid())
|
||||
{
|
||||
// overlayNode->setOverlaySubgraph(overlaySubGraph);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ class OSG_EXPORT Geode : public Node
|
||||
* @return \c true if at least one \c Drawable was removed. \c false
|
||||
* otherwise.
|
||||
*/
|
||||
virtual bool removeDrawable(unsigned int i,unsigned int numDrawablesToRemove=1);
|
||||
virtual bool removeDrawables(unsigned int i,unsigned int numDrawablesToRemove=1);
|
||||
|
||||
/** Replace specified Drawable with another Drawable.
|
||||
* Equivalent to <tt>setDrawable(getDrawableIndex(origDraw),newDraw)</tt>,
|
||||
|
@ -63,10 +63,32 @@ class OSG_EXPORT Group : public Node
|
||||
* bounding sphere to force it to recompute on next getBound() and
|
||||
* return true for success. If Node is not found then return false
|
||||
* and do not change the reference count of the Node.
|
||||
* Note, do not override, only override removeChildren(,) is required.
|
||||
*/
|
||||
virtual bool removeChild( Node *child );
|
||||
inline bool removeChild( Node *child )
|
||||
{
|
||||
unsigned int pos = getChildIndex(child);
|
||||
if (pos<_children.size()) return removeChildren(pos,1);
|
||||
else return false;
|
||||
}
|
||||
|
||||
virtual bool removeChild(unsigned int pos,unsigned int numChildrenToRemove=1);
|
||||
/** Remove Node from Group.
|
||||
* If Node is contained in Group then remove it from the child
|
||||
* list, decrement its reference count, and dirty the
|
||||
* bounding sphere to force it to recompute on next getBound() and
|
||||
* return true for success. If Node is not found then return false
|
||||
* and do not change the reference count of the Node.
|
||||
* Note, do not override, only override removeChildren(,) is required.
|
||||
*/
|
||||
inline bool removeChild( unsigned int pos )
|
||||
{
|
||||
if (pos<_children.size()) return removeChildren(pos,1);
|
||||
else return false;
|
||||
}
|
||||
|
||||
/** Remove children from Group.
|
||||
* Note, must be override by subclasses of Group which add per child attributes.*/
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
|
||||
|
||||
/** Replace specified Node with another Node.
|
||||
* Equivalent to setChild(getChildIndex(orignChild),node)
|
||||
|
@ -49,8 +49,7 @@ class OSG_EXPORT LOD : public Group
|
||||
|
||||
virtual bool addChild(Node *child, float min, float max);
|
||||
|
||||
virtual bool removeChild(Node *child);
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove=1);
|
||||
|
||||
typedef std::pair<float,float> MinMaxPair;
|
||||
typedef std::vector<MinMaxPair> RangeList;
|
||||
@ -124,12 +123,6 @@ class OSG_EXPORT LOD : public Group
|
||||
protected :
|
||||
virtual ~LOD() {}
|
||||
|
||||
virtual void childRemoved(unsigned int pos, unsigned int numChildrenToRemove);
|
||||
virtual void childInserted(unsigned int pos);
|
||||
|
||||
virtual void rangeRemoved(unsigned int /*pos*/, unsigned int /*numChildrenToRemove*/) {}
|
||||
virtual void rangeInserted(unsigned int /*pos*/) {}
|
||||
|
||||
CenterMode _centerMode;
|
||||
Vec3 _userDefinedCenter;
|
||||
float _radius;
|
||||
|
@ -41,8 +41,7 @@ class OSG_EXPORT PagedLOD : public LOD
|
||||
|
||||
virtual bool addChild(Node *child, float min, float max,const std::string& filename, float priorityOffset=0.0f, float priorityScale=1.0f);
|
||||
|
||||
virtual bool removeChild(Node *child);
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove=1);
|
||||
|
||||
|
||||
|
||||
@ -113,12 +112,6 @@ class OSG_EXPORT PagedLOD : public LOD
|
||||
|
||||
virtual ~PagedLOD() {}
|
||||
|
||||
virtual void childRemoved(unsigned int pos, unsigned int numChildrenToRemove);
|
||||
virtual void childInserted(unsigned int pos);
|
||||
|
||||
virtual void rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove);
|
||||
virtual void rangeInserted(unsigned int pos);
|
||||
|
||||
void expandPerRangeDataTo(unsigned int pos);
|
||||
|
||||
std::string _databasePath;
|
||||
|
@ -35,7 +35,8 @@ class OSG_EXPORT ProxyNode : public Group
|
||||
|
||||
virtual bool addChild(Node *child);
|
||||
virtual bool addChild(Node *child, const std::string& filename);
|
||||
virtual bool removeChild(Node *child);
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
|
||||
|
||||
/** Set the database path to prepend to children's filenames.*/
|
||||
void setDatabasePath(const std::string& path);
|
||||
|
@ -49,9 +49,7 @@ class OSG_EXPORT Switch : public Group
|
||||
|
||||
virtual bool insertChild( unsigned int index, Node *child, bool value );
|
||||
|
||||
virtual bool removeChild( Node *child );
|
||||
|
||||
virtual bool removeChild(unsigned int pos,unsigned int numChildrenToRemove=1);
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
|
||||
|
||||
|
||||
void setValue(unsigned int pos,bool value);
|
||||
|
@ -77,10 +77,10 @@ bool Geode::addDrawable( Drawable *drawable )
|
||||
|
||||
bool Geode::removeDrawable( Drawable *drawable )
|
||||
{
|
||||
return removeDrawable(getDrawableIndex(drawable));
|
||||
return removeDrawables(getDrawableIndex(drawable),1);
|
||||
}
|
||||
|
||||
bool Geode::removeDrawable(unsigned int pos,unsigned int numDrawablesToRemove)
|
||||
bool Geode::removeDrawables(unsigned int pos,unsigned int numDrawablesToRemove)
|
||||
{
|
||||
if (pos<_drawables.size() && numDrawablesToRemove>0)
|
||||
{
|
||||
|
@ -144,12 +144,7 @@ bool Group::insertChild( unsigned int index, Node *child )
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool Group::removeChild( Node *child )
|
||||
{
|
||||
return removeChild(getChildIndex(child));
|
||||
}
|
||||
|
||||
bool Group::removeChild(unsigned int pos,unsigned int numChildrenToRemove)
|
||||
bool Group::removeChildren(unsigned int pos,unsigned int numChildrenToRemove)
|
||||
{
|
||||
if (pos<_children.size() && numChildrenToRemove>0)
|
||||
{
|
||||
|
@ -113,16 +113,6 @@ bool LOD::addChild( Node *child )
|
||||
return false;
|
||||
}
|
||||
|
||||
void LOD::childRemoved(unsigned int /*pos*/, unsigned int /*numChildrenToRemove*/)
|
||||
{
|
||||
//std::cout<<"LOD::childRemoved("<<pos<<","<<numChildrenToRemove<<")"<<std::endl;
|
||||
}
|
||||
|
||||
void LOD::childInserted(unsigned int /*pos*/)
|
||||
{
|
||||
//std::cout<<"LOD::childInserted("<<pos<<")"<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
bool LOD::addChild(Node *child, float min, float max)
|
||||
{
|
||||
@ -136,15 +126,11 @@ bool LOD::addChild(Node *child, float min, float max)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LOD::removeChild( Node *child )
|
||||
bool LOD::removeChildren( unsigned int pos,unsigned int numChildrenToRemove)
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return false;
|
||||
if (pos<_rangeList.size()) _rangeList.erase(_rangeList.begin()+pos, osg::minimum(_rangeList.begin()+(pos+numChildrenToRemove), _rangeList.end()) );
|
||||
|
||||
_rangeList.erase(_rangeList.begin()+pos);
|
||||
|
||||
return Group::removeChild(child);
|
||||
return Group::removeChildren(pos,numChildrenToRemove);
|
||||
}
|
||||
|
||||
void LOD::setRange(unsigned int childNo, float min,float max)
|
||||
|
@ -208,27 +208,6 @@ void PagedLOD::traverse(NodeVisitor& nv)
|
||||
}
|
||||
|
||||
|
||||
void PagedLOD::childRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||
{
|
||||
LOD::childRemoved(pos, numChildrenToRemove);
|
||||
}
|
||||
|
||||
void PagedLOD::childInserted(unsigned int pos)
|
||||
{
|
||||
LOD::childInserted(pos);
|
||||
}
|
||||
|
||||
void PagedLOD::rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove)
|
||||
{
|
||||
LOD::rangeRemoved(pos, numChildrenToRemove);
|
||||
}
|
||||
|
||||
void PagedLOD::rangeInserted(unsigned int pos)
|
||||
{
|
||||
LOD::rangeInserted(pos);
|
||||
expandPerRangeDataTo(pos);
|
||||
}
|
||||
|
||||
void PagedLOD::expandPerRangeDataTo(unsigned int pos)
|
||||
{
|
||||
if (pos>=_perRangeDataList.size()) _perRangeDataList.resize(pos+1);
|
||||
@ -267,16 +246,12 @@ bool PagedLOD::addChild(Node *child, float min, float max,const std::string& fil
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PagedLOD::removeChild( Node *child )
|
||||
bool PagedLOD::removeChildren( unsigned int pos,unsigned int numChildrenToRemove)
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return false;
|
||||
if (pos<_rangeList.size()) _rangeList.erase(_rangeList.begin()+pos, osg::minimum(_rangeList.begin()+(pos+numChildrenToRemove), _rangeList.end()) );
|
||||
if (pos<_perRangeDataList.size()) _perRangeDataList.erase(_perRangeDataList.begin()+pos, osg::minimum(_perRangeDataList.begin()+ (pos+numChildrenToRemove), _perRangeDataList.end()) );
|
||||
|
||||
if (pos<_rangeList.size()) _rangeList.erase(_rangeList.begin()+pos);
|
||||
if (pos<_perRangeDataList.size()) _perRangeDataList.erase(_perRangeDataList.begin()+pos);
|
||||
|
||||
return Group::removeChild(child);
|
||||
return Group::removeChildren(pos,numChildrenToRemove);
|
||||
}
|
||||
|
||||
bool PagedLOD::removeExpiredChildren(double expiryTime,NodeList& removedChildren)
|
||||
|
@ -92,15 +92,11 @@ bool ProxyNode::addChild(Node *child, const std::string& filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProxyNode::removeChild( Node *child )
|
||||
bool ProxyNode::removeChildren(unsigned int pos,unsigned int numChildrenToRemove)
|
||||
{
|
||||
// find the child's position.
|
||||
unsigned int pos=getChildIndex(child);
|
||||
if (pos==_children.size()) return false;
|
||||
if (pos<_filenameList.size()) _filenameList.erase(_filenameList.begin()+pos, osg::minimum(_filenameList.begin()+(pos+numChildrenToRemove), _filenameList.end()) );
|
||||
|
||||
if (pos<_filenameList.size()) _filenameList.erase(_filenameList.begin()+pos);
|
||||
|
||||
return Group::removeChild(child);
|
||||
return Group::removeChildren(pos,numChildrenToRemove);
|
||||
}
|
||||
|
||||
BoundingSphere ProxyNode::computeBound() const
|
||||
|
@ -99,25 +99,11 @@ bool Switch::insertChild( unsigned int index, Node *child, bool value )
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Switch::removeChild( Node *child )
|
||||
bool Switch::removeChildren(unsigned int pos,unsigned int numChildrenToRemove)
|
||||
{
|
||||
return removeChild( getChildIndex(child) );
|
||||
}
|
||||
if (pos<_values.size()) _values.erase(_values.begin()+pos, osg::minimum(_values.begin()+(pos+numChildrenToRemove), _values.end()) );
|
||||
|
||||
bool Switch::removeChild(unsigned int pos,unsigned int numChildrenToRemove)
|
||||
{
|
||||
if (pos>=_values.size() || numChildrenToRemove==0) return false;
|
||||
|
||||
unsigned int endOfRemoveRange = pos+numChildrenToRemove;
|
||||
if (endOfRemoveRange>_values.size())
|
||||
{
|
||||
notify(DEBUG_INFO)<<"Warning: Switch::removeChild(i,numChildrenToRemove) has been passed an excessive number"<<std::endl;
|
||||
notify(DEBUG_INFO)<<" of chilren to remove, trimming just to end of value list."<<std::endl;
|
||||
endOfRemoveRange=_values.size();
|
||||
}
|
||||
_values.erase(_values.begin()+pos,_values.begin()+endOfRemoveRange);
|
||||
|
||||
return Group::removeChild(pos, numChildrenToRemove);
|
||||
return Group::removeChildren(pos,numChildrenToRemove);
|
||||
}
|
||||
|
||||
void Switch::setValue(unsigned int pos,bool value)
|
||||
|
@ -150,7 +150,7 @@ void ParticleEffect::buildEffect()
|
||||
|
||||
|
||||
// clear the children.
|
||||
removeChild(0,getNumChildren());
|
||||
removeChildren(0,getNumChildren());
|
||||
|
||||
// add the emitter
|
||||
addChild(emitter.get());
|
||||
|
@ -219,7 +219,7 @@ void ESRIShapeParser::_combinePointToMultipoint()
|
||||
}
|
||||
}
|
||||
|
||||
_geode->removeDrawable( 0, numDrawables );
|
||||
_geode->removeDrawables( 0, numDrawables );
|
||||
|
||||
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
|
||||
geometry->setVertexArray(coords.get());
|
||||
|
@ -12,16 +12,14 @@
|
||||
#include <osg/CullFace>
|
||||
#include <osg/PolygonOffset>
|
||||
#include <osg/Depth>
|
||||
#include <osg/ShadeModel>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osgUtil/Tesselator>
|
||||
#include <osgUtil/SmoothingVisitor>
|
||||
#include "Registry.h"
|
||||
#include "Document.h"
|
||||
#include "RecordInputStream.h"
|
||||
|
||||
namespace flt {
|
||||
|
||||
|
||||
class Face : public PrimaryRecord
|
||||
{
|
||||
// flags
|
||||
@ -134,9 +132,9 @@ public:
|
||||
|
||||
virtual osg::Vec4 getPrimaryColor() const { return _primaryColor; }
|
||||
inline int getMaterialIndex() const { return _materialIndex; }
|
||||
inline int getTextureIndex() const { return _textureIndex; }
|
||||
inline int getTextureMappingIndex() const { return _textureMappingIndex; }
|
||||
inline float getTransparency() const { return (float)_transparency / 65535.0f; }
|
||||
inline int getTextureIndex() const { return _textureIndex; }
|
||||
inline int getTextureMappingIndex() const { return _textureMappingIndex; }
|
||||
inline float getTransparency() const { return (float)_transparency / 65535.0f; }
|
||||
inline bool isTransparent() const { return _transparency > 0; }
|
||||
|
||||
virtual void addChild(osg::Node& child)
|
||||
@ -284,7 +282,7 @@ protected:
|
||||
_geode->addDrawable(_geometry.get());
|
||||
|
||||
// StateSet
|
||||
osg::StateSet* stateset = _geode->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||
|
||||
// Hidden
|
||||
if (isHidden())
|
||||
@ -362,7 +360,8 @@ protected:
|
||||
// Enable alpha blend?
|
||||
if (isAlphaBlend() || isTransparent() || isTransparentMaterial || isImageTranslucent)
|
||||
{
|
||||
stateset->setAttributeAndModes(new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA), osg::StateAttribute::ON);
|
||||
static osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
|
||||
stateset->setAttributeAndModes(blendFunc.get(), osg::StateAttribute::ON);
|
||||
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
}
|
||||
|
||||
@ -370,8 +369,11 @@ protected:
|
||||
switch(_drawFlag)
|
||||
{
|
||||
case SOLID_BACKFACED: // Enable backface culling
|
||||
stateset->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK), osg::StateAttribute::ON);
|
||||
{
|
||||
static osg::ref_ptr<osg::CullFace> cullFace = new osg::CullFace(osg::CullFace::BACK);
|
||||
stateset->setAttributeAndModes(cullFace.get(), osg::StateAttribute::ON);
|
||||
break;
|
||||
}
|
||||
case SOLID_NO_BACKFACE: // Disable backface culling
|
||||
stateset->setMode(GL_CULL_FACE,osg::StateAttribute::OFF);
|
||||
break;
|
||||
@ -380,17 +382,23 @@ protected:
|
||||
// Subface
|
||||
if (document.subfaceLevel() > 0)
|
||||
{
|
||||
osg::PolygonOffset* polyoffset = new osg::PolygonOffset;
|
||||
polyoffset->setFactor(-10.0f);
|
||||
polyoffset->setUnits(-40.0f);
|
||||
stateset->setAttributeAndModes(polyoffset, osg::StateAttribute::ON);
|
||||
static osg::ref_ptr<osg::PolygonOffset> polygonOffset = new osg::PolygonOffset(-10.0f, -40.0f);
|
||||
stateset->setAttributeAndModes(polygonOffset.get(), osg::StateAttribute::ON);
|
||||
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
depth->setWriteMask(false);
|
||||
stateset->setAttribute(depth);
|
||||
static osg::ref_ptr<osg::Depth> depth = new osg::Depth(osg::Depth::LESS, 0.0, 1.0,false);
|
||||
stateset->setAttribute(depth.get());
|
||||
|
||||
stateset->setRenderBinDetails(document.subfaceLevel(),"RenderBin");
|
||||
}
|
||||
#if 1
|
||||
// A simple share stateset optimization.
|
||||
static osg::ref_ptr<osg::StateSet> lastStateset;
|
||||
if (lastStateset.valid() && (stateset->compare(*lastStateset,false)==0))
|
||||
stateset = lastStateset;
|
||||
else
|
||||
lastStateset = stateset;
|
||||
#endif
|
||||
_geode->setStateSet(stateset.get());
|
||||
|
||||
// Add to parent.
|
||||
if (_parent.valid())
|
||||
@ -623,3 +631,15 @@ protected:
|
||||
RegisterRecordProxy<MorphVertexList> g_MorphVertexList(MORPH_VERTEX_LIST_OP);
|
||||
|
||||
} // end namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -128,9 +128,13 @@ protected:
|
||||
// Flat shaded?
|
||||
if (flags & FLAT_SHADED)
|
||||
{
|
||||
osg::ShadeModel* shademodel = new osg::ShadeModel;
|
||||
shademodel->setMode(osg::ShadeModel::FLAT);
|
||||
_object->getOrCreateStateSet()->setAttribute(shademodel);
|
||||
static osg::ref_ptr<osg::ShadeModel> shademodel;
|
||||
if (!shademodel.valid())
|
||||
{
|
||||
shademodel = new osg::ShadeModel;
|
||||
shademodel->setMode(osg::ShadeModel::FLAT);
|
||||
}
|
||||
_object->getOrCreateStateSet()->setAttribute(shademodel.get());
|
||||
}
|
||||
|
||||
if (_parent.valid())
|
||||
@ -745,3 +749,15 @@ RegisterRecordProxy<Extension> g_Extension(EXTENSION_OP);
|
||||
|
||||
|
||||
} // end namespace
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -47,7 +47,9 @@ ReaderWriter::ReadResult ReaderWriterATTR::readObject(const std::string& file, c
|
||||
std::string fileName = osgDB::findDataFile( file, options );
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
std::ifstream fin(fileName.c_str(), ios::in | ios::binary);
|
||||
std::ifstream fin;
|
||||
fin.imbue(std::locale::classic());
|
||||
fin.open(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
if ( fin.fail())
|
||||
return ReadResult::ERROR_IN_READING_FILE;
|
||||
@ -175,3 +177,15 @@ ReaderWriter::ReadResult ReaderWriterATTR::readObject(const std::string& file, c
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriterATTR> g_readerWriter_ATTR_Proxy;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -53,9 +53,11 @@ class FLTReaderWriter : public ReaderWriter
|
||||
// code for setting up the database path so that internally referenced file are searched for on relative paths.
|
||||
osg::ref_ptr<Options> local_opt = options ? static_cast<Options*>(options->clone(osg::CopyOp::SHALLOW_COPY)) : new Options;
|
||||
local_opt->setDatabasePath(osgDB::getFilePath(fileName));
|
||||
// local_opt->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
|
||||
|
||||
std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
std::ifstream istream;
|
||||
istream.imbue(std::locale::classic());
|
||||
istream.open(fileName.c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
return readNode(istream,local_opt.get());
|
||||
}
|
||||
|
||||
@ -185,3 +187,15 @@ class FLTReaderWriter : public ReaderWriter
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
RegisterReaderWriterProxy<FLTReaderWriter> g_FLTReaderWriterProxy;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ Converter::Converter(const Options &options, const osgDB::ReaderWriter::Options*
|
||||
osg::Group *Converter::convert(Object &obj)
|
||||
{
|
||||
if (root_->getNumChildren() > 0) {
|
||||
root_->removeChild(0, root_->getNumChildren());
|
||||
root_->removeChildren(0, root_->getNumChildren());
|
||||
}
|
||||
|
||||
osg::notify(osg::INFO) << "INFO: lwosg::Converter: flattening per-polygon vertex maps\n";
|
||||
|
@ -1175,7 +1175,7 @@ void Optimizer::RemoveEmptyNodesVisitor::apply(osg::Geode& geode)
|
||||
osg::Geometry* geom = geode.getDrawable(i)->asGeometry();
|
||||
if (geom && geom->empty() && isOperationPermissibleForObject(geom))
|
||||
{
|
||||
geode.removeDrawable(i);
|
||||
geode.removeDrawables(i,1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2328,7 +2328,7 @@ bool Optimizer::SpatializeGroupsVisitor::divide(osg::Group* group, unsigned int
|
||||
|
||||
|
||||
// first removing from the original group,
|
||||
group->removeChild(0,group->getNumChildren());
|
||||
group->removeChildren(0,group->getNumChildren());
|
||||
|
||||
// add in the bb groups
|
||||
typedef std::vector< osg::ref_ptr<osg::Group> > GroupList;
|
||||
|
@ -226,7 +226,7 @@ void SceneView::setSceneData(osg::Node* node)
|
||||
osg::ref_ptr<osg::Node> temporaryRefernce = node;
|
||||
|
||||
// remove pre existing children
|
||||
_camera->removeChild(0, _camera->getNumChildren());
|
||||
_camera->removeChildren(0, _camera->getNumChildren());
|
||||
|
||||
// add the new one in.
|
||||
_camera->addChild(node);
|
||||
|
Loading…
Reference in New Issue
Block a user