Skip to content

Commit

Permalink
ExtrudeGeometryFilter: add a pathway for extruding downwards with the…
Browse files Browse the repository at this point in the history
… 'roof' at the bottom
  • Loading branch information
gwaldron committed Feb 25, 2025
1 parent 4a5f87e commit fe6ef02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/osgEarth/ExtrudeGeometryFilter
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ namespace osgEarth { namespace Util
osg::ref_ptr<ResourceLibrary> _wallResLib;
osg::ref_ptr<ResourceLibrary> _roofResLib;

bool _extrudeDownToGround = false;

void reset( const FilterContext& context );

void addDrawable(
Expand Down
14 changes: 7 additions & 7 deletions src/osgEarth/ExtrudeGeometryFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ ExtrudeGeometryFilter::reset( const FilterContext& context )
alt->clamping() == AltitudeSymbol::CLAMP_RELATIVE_TO_TERRAIN )
{
_heightExpr = NumericExpression( "0-[__max_hat]" );
_extrudeDownToGround = true;
}
}

Expand Down Expand Up @@ -363,19 +364,18 @@ ExtrudeGeometryFilter::buildStructure(const Geometry* input,
corner->isFromSource = true;
corner->base = *point;

// extrude:
if ( height >= 0 ) // extrude up
if (_extrudeDownToGround && height < 0)
{
corner->roof = *point;
corner->base.z() += height;
}
else
{
if ( flatten )
corner->roof.set( corner->base.x(), corner->base.y(), targetLen );
else
corner->roof.set( corner->base.x(), corner->base.y(), corner->base.z() + height );
}
else // height < 0 .. extrude down
{
corner->roof = *point;
corner->base.z() += height;
}

// figure out the rooftop texture coords before doing any transformation:
if ( roofSkin && srs )
Expand Down

0 comments on commit fe6ef02

Please sign in to comment.