Implemented duplicate removal code into TriStripVisitor and added an
extra pass to doing tri stripping in the osgUtil::Optimzer. Added validity checks into osg::TexEnvCombine to catch eronous enumarant values. Improved the efficient of CullingSet's handling of new transforms. Added a copy shared subgraphs and subdivision code into osgUtil::Optimizer.
This commit is contained in:
@@ -73,6 +73,9 @@ class SG_EXPORT Array : public Object
|
||||
virtual void accept(unsigned int index,ValueVisitor&) = 0;
|
||||
virtual void accept(unsigned int index,ConstValueVisitor&) const = 0;
|
||||
|
||||
/** return -1 if lhs element is less than rhs element, 0 is equal, 1 if lhs element is greater than rhs element.*/
|
||||
virtual int compare(unsigned int lhs,unsigned int rhs) const = 0;
|
||||
|
||||
Type getType() const { return _arrayType; }
|
||||
GLint getDataSize() const { return _dataSize; }
|
||||
GLenum getDataType() const { return _dataType; }
|
||||
@@ -122,6 +125,15 @@ class TemplateArray : public Array, public std::vector<T>
|
||||
virtual void accept(unsigned int index,ValueVisitor& vv) { vv.apply( (*this)[index] ); }
|
||||
virtual void accept(unsigned int index,ConstValueVisitor& vv) const { vv.apply( (*this)[index] );}
|
||||
|
||||
virtual int compare(unsigned int lhs,unsigned int rhs) const
|
||||
{
|
||||
const T& elem_lhs = (*this)[lhs];
|
||||
const T& elem_rhs = (*this)[rhs];
|
||||
if (elem_lhs<elem_rhs) return -1;
|
||||
if (elem_rhs<elem_lhs) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual const GLvoid* getDataPointer() const { if (!empty()) return &front(); else return 0; }
|
||||
virtual unsigned int getTotalDataSize() const { return size()*sizeof(T); }
|
||||
virtual unsigned int getNumElements() const { return size(); }
|
||||
@@ -184,6 +196,15 @@ class TemplateIndexArray : public IndexArray, public std::vector<T>
|
||||
virtual void accept(unsigned int index,ValueVisitor& vv) { vv.apply( (*this)[index] ); }
|
||||
virtual void accept(unsigned int index,ConstValueVisitor& vv) const { vv.apply( (*this)[index] );}
|
||||
|
||||
virtual int compare(unsigned int lhs,unsigned int rhs) const
|
||||
{
|
||||
const T& elem_lhs = (*this)[lhs];
|
||||
const T& elem_rhs = (*this)[rhs];
|
||||
if (elem_lhs<elem_rhs) return -1;
|
||||
if (elem_rhs<elem_lhs) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual const GLvoid* getDataPointer() const { if (!empty()) return &front(); else return 0; }
|
||||
virtual unsigned int getTotalDataSize() const { return size()*sizeof(T); }
|
||||
virtual unsigned int getNumElements() const { return size(); }
|
||||
|
||||
@@ -81,12 +81,14 @@ class SG_EXPORT CullingSet : public Referenced
|
||||
inline void set(const CullingSet& cs,const Matrix& matrix, const Vec4& pixelSizeVector)
|
||||
{
|
||||
_mask = cs._mask;
|
||||
_frustum = cs._frustum;
|
||||
_occluderList = cs._occluderList;
|
||||
_pixelSizeVector = pixelSizeVector;
|
||||
_smallFeatureCullingPixelSize = cs._smallFeatureCullingPixelSize;
|
||||
|
||||
_frustum.transformProvidingInverse(matrix);
|
||||
//_frustum = cs._frustum;
|
||||
//_frustum.transformProvidingInverse(matrix);
|
||||
|
||||
_frustum.setAndTransformProvidingInverse(cs._frustum,matrix);
|
||||
|
||||
for(OccluderList::iterator itr=_occluderList.begin();
|
||||
itr!=_occluderList.end();
|
||||
|
||||
@@ -58,6 +58,8 @@ class SG_EXPORT Geometry : public Drawable
|
||||
normalize(GL_FALSE),
|
||||
offset(0) {}
|
||||
|
||||
ArrayData(const ArrayData& data,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
ArrayData(Array* a, AttributeBinding b, GLboolean n = GL_FALSE):
|
||||
array(a),
|
||||
indices(0),
|
||||
@@ -96,6 +98,8 @@ class SG_EXPORT Geometry : public Drawable
|
||||
normalize(GL_FALSE),
|
||||
offset(0) {}
|
||||
|
||||
Vec3ArrayData(const Vec3ArrayData& data,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
Vec3ArrayData(Vec3Array* a, AttributeBinding b, GLboolean n = GL_FALSE):
|
||||
array(a),
|
||||
indices(0),
|
||||
@@ -357,24 +361,15 @@ class SG_EXPORT Geometry : public Drawable
|
||||
|
||||
|
||||
PrimitiveSetList _primitives;
|
||||
|
||||
ArrayData _vertexData;
|
||||
|
||||
Vec3ArrayData _normalData;
|
||||
|
||||
ArrayData _colorData;
|
||||
|
||||
ArrayData _secondaryColorData;
|
||||
|
||||
ArrayData _fogCoordData;
|
||||
|
||||
ArrayList _texCoordList;
|
||||
|
||||
ArrayList _vertexAttribList;
|
||||
|
||||
|
||||
mutable bool _fastPath;
|
||||
|
||||
bool _fastPathHint;
|
||||
|
||||
ref_ptr<Geometry> _internalOptimizedGeometry;
|
||||
|
||||
@@ -77,7 +77,7 @@ class SG_EXPORT Multisample : public StateAttribute
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual void getAssociatedModes(std::vector<GLMode>& modes) const {}
|
||||
virtual void getAssociatedModes(std::vector<GLMode>& /*modes*/) const {}
|
||||
|
||||
void setSampleCoverage(float coverage, bool invert)
|
||||
{
|
||||
|
||||
@@ -69,8 +69,56 @@ class SG_EXPORT Polytope
|
||||
setupMask();
|
||||
}
|
||||
|
||||
inline void setAndTransformProvidingInverse(const Polytope& pt, const osg::Matrix& matrix)
|
||||
{
|
||||
_referenceVertexList = pt._referenceVertexList;
|
||||
|
||||
unsigned int resultMask = pt._maskStack.back();
|
||||
if (resultMask==0)
|
||||
{
|
||||
_maskStack.back() = 0;
|
||||
_resultMask = 0;
|
||||
_planeList.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
ClippingMask selector_mask = 0x1;
|
||||
|
||||
unsigned int numActivePlanes = 0;
|
||||
|
||||
// count number active planes.
|
||||
PlaneList::const_iterator itr;
|
||||
for(itr=pt._planeList.begin();
|
||||
itr!=pt._planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (resultMask&selector_mask) ++numActivePlanes;
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
|
||||
_planeList.resize(numActivePlanes);
|
||||
_resultMask = 0;
|
||||
selector_mask = 0x1;
|
||||
unsigned int index = 0;
|
||||
for(itr=pt._planeList.begin();
|
||||
itr!=pt._planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (resultMask&selector_mask)
|
||||
{
|
||||
_planeList[index] = *itr;
|
||||
_planeList[index++].transformProvidingInverse(matrix);
|
||||
_resultMask = (_resultMask<<1) | 1;
|
||||
}
|
||||
selector_mask <<= 1;
|
||||
}
|
||||
|
||||
_maskStack.back() = _resultMask;
|
||||
}
|
||||
|
||||
inline void set(const PlaneList& pl) { _planeList = pl; setupMask(); }
|
||||
|
||||
|
||||
inline void add(const osg::Plane& pl) { _planeList.push_back(pl); setupMask(); }
|
||||
|
||||
/** flip/reverse the orientation of all the planes.*/
|
||||
|
||||
@@ -134,8 +134,8 @@ class SG_EXPORT TexEnvCombine : public StateAttribute
|
||||
DOT3_RGBA = GL_DOT3_RGBA_ARB
|
||||
};
|
||||
|
||||
void setCombine_RGB(GLint cm) { _combine_RGB = cm; }
|
||||
void setCombine_Alpha(GLint cm) { _combine_Alpha = cm; }
|
||||
void setCombine_RGB(GLint cm);
|
||||
void setCombine_Alpha(GLint cm);
|
||||
|
||||
GLint getCombine_RGB() const { return _combine_RGB; }
|
||||
GLint getCombine_Alpha() const { return _combine_Alpha; }
|
||||
@@ -156,13 +156,13 @@ class SG_EXPORT TexEnvCombine : public StateAttribute
|
||||
TEXTURE7 = GL_TEXTURE0+7
|
||||
};
|
||||
|
||||
void setSource0_RGB(GLint sp) { _source0_RGB = sp; computeNeedoForTexEnvCombiners(); }
|
||||
void setSource1_RGB(GLint sp) { _source1_RGB = sp; computeNeedoForTexEnvCombiners(); }
|
||||
void setSource2_RGB(GLint sp) { _source2_RGB = sp; computeNeedoForTexEnvCombiners(); }
|
||||
void setSource0_RGB(GLint sp);
|
||||
void setSource1_RGB(GLint sp);
|
||||
void setSource2_RGB(GLint sp);
|
||||
|
||||
void setSource0_Alpha(GLint sp) { _source0_Alpha = sp; computeNeedoForTexEnvCombiners(); }
|
||||
void setSource1_Alpha(GLint sp) { _source1_Alpha = sp; computeNeedoForTexEnvCombiners(); }
|
||||
void setSource2_Alpha(GLint sp) { _source2_Alpha = sp; computeNeedoForTexEnvCombiners(); }
|
||||
void setSource0_Alpha(GLint sp);
|
||||
void setSource1_Alpha(GLint sp);
|
||||
void setSource2_Alpha(GLint sp);
|
||||
|
||||
GLint getSource0_RGB() const { return _source0_RGB; }
|
||||
GLint getSource1_RGB() const { return _source1_RGB; }
|
||||
@@ -180,13 +180,13 @@ class SG_EXPORT TexEnvCombine : public StateAttribute
|
||||
ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA
|
||||
};
|
||||
|
||||
void setOperand0_RGB(GLint op) { _operand0_RGB = op; }
|
||||
void setOperand1_RGB(GLint op) { _operand1_RGB = op; }
|
||||
void setOperand2_RGB(GLint op) { _operand2_RGB = op; }
|
||||
void setOperand0_RGB(GLint op);
|
||||
void setOperand1_RGB(GLint op);
|
||||
void setOperand2_RGB(GLint op);
|
||||
|
||||
void setOperand0_Alpha(GLint op) { _operand0_Alpha = op; }
|
||||
void setOperand1_Alpha(GLint op) { _operand1_Alpha = op; }
|
||||
void setOperand2_Alpha(GLint op) { _operand2_Alpha = op; }
|
||||
void setOperand0_Alpha(GLint op);
|
||||
void setOperand1_Alpha(GLint op);
|
||||
void setOperand2_Alpha(GLint op);
|
||||
|
||||
GLint getOperand0_RGB() const { return _operand0_RGB; }
|
||||
GLint getOperand1_RGB() const { return _operand1_RGB; }
|
||||
@@ -197,8 +197,8 @@ class SG_EXPORT TexEnvCombine : public StateAttribute
|
||||
GLint getOperand2_Alpha() const { return _operand2_Alpha; }
|
||||
|
||||
|
||||
void setScale_RGB(float scale) { _scale_RGB = scale; }
|
||||
void setScale_Alpha(float scale) { _scale_Alpha = scale; }
|
||||
void setScale_RGB(float scale);
|
||||
void setScale_Alpha(float scale);
|
||||
|
||||
float getScale_RGB() const { return _scale_RGB; }
|
||||
float getScale_Alpha() const { return _scale_Alpha; }
|
||||
|
||||
Reference in New Issue
Block a user