diff --git a/src/osgPlugins/freetype/FreeTypeFont3D.cpp b/src/osgPlugins/freetype/FreeTypeFont3D.cpp index 98db67e0a..1b4ac9683 100644 --- a/src/osgPlugins/freetype/FreeTypeFont3D.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont3D.cpp @@ -32,7 +32,7 @@ #include #include - +#include namespace { @@ -67,7 +67,19 @@ struct Char3DInfo return _geometry.get(); } - void moveTo(osg::Vec2 pos) + void addVertex(const osg::Vec3& pos) + { + if (!_verts->empty() && _verts->back()==pos) + { + // OSG_NOTICE<<"addVertex("<push_back( pos ); + setMinMax(pos); + } + + void moveTo(const osg::Vec2& pos) { if (_verts->size()) { @@ -75,16 +87,14 @@ struct Char3DInfo _geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::POLYGON, _idx, len ) ); } _idx = _verts->size(); - _verts->push_back( osg::Vec3(pos.x(),pos.y(),0) ); + addVertex( osg::Vec3(pos.x(),pos.y(),0) ); - setMinMax(pos); } - void lineTo(osg::Vec2 pos) + void lineTo(const osg::Vec2& pos) { - _verts->push_back( osg::Vec3(pos.x(),pos.y(),0) ); - setMinMax(pos); + addVertex( osg::Vec3(pos.x(),pos.y(),0) ); } - void conicTo(osg::Vec2 control, osg::Vec2 pos) + void conicTo(const osg::Vec2& control, const osg::Vec2& pos) { osg::Vec3 p0 = _verts->back(); osg::Vec3 p1 = osg::Vec3(control.x(),control.y(),0); @@ -97,15 +107,13 @@ struct Char3DInfo double w = 1; double bs = 1.0/( (1-u)*(1-u)+2*(1-u)*u*w +u*u ); osg::Vec3 p = (p0*((1-u)*(1-u)) + p1*(2*(1-u)*u*w) + p2*(u*u))*bs; - _verts->push_back( p ); + addVertex( p ); u += dt; } - - setMinMax(pos); } - void cubicTo(osg::Vec2 control1, osg::Vec2 control2, osg::Vec2 pos) + void cubicTo(const osg::Vec2& control1, const osg::Vec2& control2, const osg::Vec2& pos) { osg::Vec3 p0 = _verts->back(); osg::Vec3 p1 = osg::Vec3(control1.x(),control1.y(),0); @@ -124,15 +132,13 @@ struct Char3DInfo for (int i=0; i<=_numSteps; ++i) { osg::Vec3 p = osg::Vec3( ax*u*u*u + bx*u*u + cx*u + p0.x(),ay*u*u*u + by*u*u + cy*u + p0.y(),0 ); - _verts->push_back( p ); + addVertex( p ); u += dt; } - - setMinMax(pos); } - void setMinMax(osg::Vec2 pos) + void setMinMax(const osg::Vec3& pos) { _maxY = std::max(_maxY, (double) pos.y()); _minY = std::min(_minY, (double) pos.y());