Smoother arc rendering in OpenGL GAL
Fixes: lp:1496114 * https://bugs.launchpad.net/kicad/+bug/1496114
This commit is contained in:
parent
3208d24ad4
commit
11f8e53e27
|
@ -532,12 +532,13 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
// Swap the angles, if start angle is greater than end angle
|
||||
SWAP( aStartAngle, >, aEndAngle );
|
||||
|
||||
const double alphaIncrement = calcAngleStep( aRadius );
|
||||
|
||||
Save();
|
||||
currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 );
|
||||
|
||||
if( isStrokeEnabled )
|
||||
{
|
||||
const double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS;
|
||||
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
|
||||
|
||||
VECTOR2D p( cos( aStartAngle ) * aRadius, sin( aStartAngle ) * aRadius );
|
||||
|
@ -561,7 +562,6 @@ void OPENGL_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double a
|
|||
|
||||
if( isFillEnabled )
|
||||
{
|
||||
const double alphaIncrement = 2 * M_PI / CIRCLE_POINTS;
|
||||
double alpha;
|
||||
currentManager->Color( fillColor.r, fillColor.g, fillColor.b, fillColor.a );
|
||||
currentManager->Shader( SHADER_NONE );
|
||||
|
@ -598,7 +598,7 @@ void OPENGL_GAL::DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, d
|
|||
// Swap the angles, if start angle is greater than end angle
|
||||
SWAP( aStartAngle, >, aEndAngle );
|
||||
|
||||
const double alphaIncrement = 2.0 * M_PI / CIRCLE_POINTS;
|
||||
const double alphaIncrement = calcAngleStep( aRadius );
|
||||
|
||||
Save();
|
||||
currentManager->Translate( aCenterPoint.x, aCenterPoint.y, 0.0 );
|
||||
|
|
|
@ -440,6 +440,15 @@ private:
|
|||
*/
|
||||
unsigned int getNewGroupNumber();
|
||||
|
||||
/**
|
||||
* @brief Compute the angle step when drawing arcs/circles approximated with lines.
|
||||
*/
|
||||
double calcAngleStep( double aRadius ) const
|
||||
{
|
||||
// Bigger arcs need smaller alpha increment to make them look smooth
|
||||
return std::min( 1e6 / aRadius, 2.0 * M_PI / CIRCLE_POINTS );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Basic OpenGL initialization.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue