Skip to content

Commit

Permalink
[3d] If a buffered line symbol is set to 0 width, transparently bump the
Browse files Browse the repository at this point in the history
width up to a tiny amount so that the tesselator actually has a (super narrow)
polygon to work from

This means that 3d buffered lines set to 0 width will actually render like
walls or fences, matching user expectations...
  • Loading branch information
nyalldawson committed Dec 7, 2020
1 parent 5be99bd commit d2f95d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/3d/symbols/qgsline3dsymbol_p.cpp
Expand Up @@ -119,7 +119,16 @@ void QgsBufferedLine3DSymbolHandler::processFeature( const QgsFeature &f, const
const double mitreLimit = 0;

QgsGeos engine( g );
QgsAbstractGeometry *buffered = engine.buffer( mSymbol->width() / 2., nSegments, endCapStyle, joinStyle, mitreLimit ); // factory

double width = mSymbol->width();
if ( qgsDoubleNear( width, 0 ) )
{
// a zero-width buffered line should be treated like a "wall" or "fence" -- we fake this by bumping the width to a very tiny amount,
// so that we get a very narrow polygon shape to work with...
width = 0.001;
}

QgsAbstractGeometry *buffered = engine.buffer( width / 2., nSegments, endCapStyle, joinStyle, mitreLimit ); // factory
if ( !buffered )
return;

Expand Down
3 changes: 1 addition & 2 deletions src/app/3d/qgsline3dsymbolwidget.cpp
Expand Up @@ -24,7 +24,7 @@ QgsLine3DSymbolWidget::QgsLine3DSymbolWidget( QWidget *parent )
setupUi( this );

spinHeight->setClearValue( 0.0 );
spinWidth->setClearValue( 0.0 );
spinWidth->setClearValue( 0.0, tr( "Hairline" ) );
spinExtrusion->setClearValue( 0.0 );

QgsLine3DSymbol defaultLine;
Expand Down Expand Up @@ -86,7 +86,6 @@ QString QgsLine3DSymbolWidget::symbolType() const
void QgsLine3DSymbolWidget::updateGuiState()
{
bool simple = chkSimpleLines->isChecked();
//spinWidth->setEnabled( !simple );
spinExtrusion->setEnabled( !simple );
widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines
: QgsMaterialSettingsRenderingTechnique::Triangles );
Expand Down

0 comments on commit d2f95d5

Please sign in to comment.