Added osg::Drawable::PrimitiveFunctor and TriangleFunctor subclass for
querrying the primitive data inside Drawables. Moved various support classes over from being osg::GeoSet based to osg::Geometry based.
This commit is contained in:
@@ -979,8 +979,55 @@ bool GeoSet::getStats(Statistics &stat)
|
||||
return true;
|
||||
}
|
||||
|
||||
void GeoSet::applyPrimitiveOperation(PrimitiveFunctor& functor)
|
||||
{
|
||||
// will easily convert into a Geometry.
|
||||
|
||||
if (!_coords || !_numcoords) return;
|
||||
|
||||
functor.setVertexArray(_numcoords,_coords);
|
||||
|
||||
if( _needprimlen )
|
||||
{
|
||||
// LINE_STRIP, LINE_LOOP, TRIANGLE_STRIP,
|
||||
// TRIANGLE_FAN, QUAD_STRIP, POLYGONS
|
||||
int index = 0;
|
||||
if( _primLengths == (int *)0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for( int i = 0; i < _numprims; i++ )
|
||||
{
|
||||
if( _cindex.valid() )
|
||||
{
|
||||
|
||||
if (_cindex._is_ushort)
|
||||
functor.drawElements( (GLenum)_oglprimtype, _primLengths[i],&_cindex._ptr._ushort[index] );
|
||||
else
|
||||
functor.drawElements( (GLenum)_oglprimtype, _primLengths[i],&_cindex._ptr._ushort[index] );
|
||||
}
|
||||
else
|
||||
functor.drawArrays( (GLenum)_oglprimtype, index, _primLengths[i] );
|
||||
|
||||
index += _primLengths[i];
|
||||
}
|
||||
}
|
||||
else // POINTS, LINES, TRIANGLES, QUADS
|
||||
{
|
||||
if( _cindex.valid())
|
||||
{
|
||||
if (_cindex._is_ushort)
|
||||
functor.drawElements( (GLenum)_oglprimtype, _cindex._size, _cindex._ptr._ushort );
|
||||
else
|
||||
functor.drawElements( (GLenum)_oglprimtype, _cindex._size, _cindex._ptr._uint );
|
||||
}
|
||||
else
|
||||
functor.drawArrays( (GLenum)_oglprimtype, 0, _numcoords );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Geometry* GeoSet::convertToGeometry()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user