Restructed and unified the position computation

This commit is contained in:
Robert Osfield
2017-02-23 15:45:43 +00:00
parent 7b3ecefcfc
commit 8ff17ddf52
7 changed files with 235 additions and 309 deletions

View File

@@ -372,8 +372,6 @@ protected:
virtual ~Text();
bool computeMatrix(osg::State& state, osg::Matrix& matrix) const;
Font* getActiveFont();
const Font* getActiveFont() const;
@@ -390,15 +388,15 @@ protected:
bool computeAverageGlyphWidthAndHeight(float& avg_width, float& avg_height) const;
virtual void computePositions(unsigned int contextID) const;
virtual void computePositionsImplementation();
void computeBackdropPositions(unsigned int contextID) const;
void computeBackdropBoundingBox() const;
void computeBoundingBoxMargin() const;
void computeBackdropPositions();
void computeBackdropBoundingBox();
void computeBoundingBoxMargin();
void computeColorGradients() const;
void computeColorGradientsOverall() const;
void computeColorGradientsPerCharacter() const;
void computeColorGradients();
void computeColorGradientsOverall();
void computeColorGradientsPerCharacter();
void drawImplementation(osg::State& state, const osg::Vec4& colorMultiplier) const;
void drawForegroundText(osg::State& state, const GlyphQuads& glyphquad, const osg::Vec4& colorMultiplier) const;

View File

@@ -109,8 +109,8 @@ class OSGTEXT_EXPORT Text3D : public osgText::TextBase
* for all graphics contexts. */
virtual void releaseGLObjects(osg::State* state=0) const;
// // make Font a friend to allow it set the _font to 0 if the font is
// // forcefully unloaded.
// make Font a friend to allow it set the _font to 0 if the font is
// forcefully unloaded.
friend class Font;
virtual osg::BoundingBox computeBoundingBox() const;
@@ -126,7 +126,6 @@ class OSGTEXT_EXPORT Text3D : public osgText::TextBase
String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
void computeGlyphRepresentation();
void computePositions(unsigned int contextID) const;
// ** glyph and other information to render the glyph
struct GlyphRenderInfo

View File

@@ -270,12 +270,13 @@ protected:
virtual ~TextBase();
bool computeMatrix(osg::Matrix& matrix, osg::State* state=0) const;
void positionCursor(const osg::Vec2 & endOfLine_coords, osg::Vec2 & cursor, unsigned int linelength);
void computePositions();
String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
void computePositions();
virtual void computePositionsImplementation();
virtual void computePositions(unsigned int contextID) const = 0;
virtual void computeGlyphRepresentation() = 0;
@@ -303,28 +304,12 @@ protected:
KerningType _kerningType;
unsigned int _lineCount;
osg::Vec3 _offset;
osg::Vec3 _normal;
osg::BoundingBox _textBB;
// internal caches of the positioning of the text.
struct AutoTransformCache
{
AutoTransformCache():
_traversalNumber(-1),
_width(0),
_height(0) {}
int _traversalNumber;
int _width;
int _height;
osg::Vec3 _transformedPosition;
osg::Matrix _matrix;
};
mutable osg::buffered_object<AutoTransformCache> _autoTransformCache;
mutable osg::Vec3 _offset;
mutable osg::Vec3 _normal;
mutable osg::BoundingBox _textBB;
mutable osg::Matrix _matrix;
void setupDecoration();