Fix intersection depth filter limit calculations

This commit is contained in:
Jon Jenssen 2022-08-01 15:42:26 +02:00 committed by Magne Sjaastad
parent 65600f58b3
commit 2e3ac5b02b
4 changed files with 17 additions and 19 deletions

View File

@ -291,11 +291,9 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
calculateLineSegementTransforms(); calculateLineSegementTransforms();
calculateTransformedPolyline(); calculateTransformedPolyline();
const double gridRadius = gridBBox.radius();
// set up our horizontal cut planes // set up our horizontal cut planes
const double topDepth = -1.0 * m_intersection->upperFilterDepth( gridRadius ); const double topDepth = m_intersection->upperFilterDepth( gridBBox.max().z() );
const double bottomDepth = -1.0 * m_intersection->lowerFilterDepth( gridRadius ); const double bottomDepth = m_intersection->lowerFilterDepth( gridBBox.min().z() );
std::array<cvf::Vec3d, 8> corners; std::array<cvf::Vec3d, 8> corners;
gridBBox.cornerVertices( corners.data() ); gridBBox.cornerVertices( corners.data() );

View File

@ -237,7 +237,7 @@ void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry()
if ( m_intersectionGenerator.isNull() ) return; if ( m_intersectionGenerator.isNull() ) return;
if ( m_rimIntersection->depthFilterType() == RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN && if ( m_rimIntersection->depthFilterType() == RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN &&
( m_rimIntersection->lowerFilterDepth( 1.0 ) <= m_rimIntersection->upperFilterDepth( 1.0 ) ) ) ( m_rimIntersection->lowerFilterDepth( 1.0 ) >= m_rimIntersection->upperFilterDepth( 1.0 ) ) )
return; return;
bool useBufferObjects = true; bool useBufferObjects = true;

View File

@ -251,10 +251,10 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
m_surfaceIntersections = new RimSurfaceIntersectionCollection; m_surfaceIntersections = new RimSurfaceIntersectionCollection;
m_surfaceIntersections->objectChanged.connect( this, &RimExtrudedCurveIntersection::onSurfaceIntersectionsChanged ); m_surfaceIntersections->objectChanged.connect( this, &RimExtrudedCurveIntersection::onSurfaceIntersectionsChanged );
CAF_PDM_InitField( &m_depthUpperThreshold, "UpperThreshold", 2000.0, "Upper Threshold" ); CAF_PDM_InitField( &m_depthUpperThreshold, "UpperThreshold", 0.0, "Upper Threshold" );
m_depthUpperThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_depthUpperThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_depthLowerThreshold, "LowerThreshold", 3000.0, "Lower Threshold" ); CAF_PDM_InitField( &m_depthLowerThreshold, "LowerThreshold", 300000.0, "Lower Threshold" );
m_depthLowerThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); m_depthLowerThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_depthFilterType, "DepthFilter", "Depth Filter" ); CAF_PDM_InitFieldNoDefault( &m_depthFilterType, "DepthFilter", "Depth Filter" );
@ -313,7 +313,7 @@ void RimExtrudedCurveIntersection::setName( const QString& newName )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
double RimExtrudedCurveIntersection::upperFilterDepth( double sceneRadius ) const double RimExtrudedCurveIntersection::upperFilterDepth( double upperGridLimit ) const
{ {
if ( m_depthThresholdOverridden ) if ( m_depthThresholdOverridden )
{ {
@ -321,12 +321,12 @@ double RimExtrudedCurveIntersection::upperFilterDepth( double sceneRadius ) cons
{ {
case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW:
case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN:
return m_collectionUpperThreshold; return -m_collectionUpperThreshold;
case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE:
case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE:
default: default:
return -sceneRadius; return upperGridLimit;
} }
} }
@ -334,12 +334,12 @@ double RimExtrudedCurveIntersection::upperFilterDepth( double sceneRadius ) cons
{ {
case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW:
case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN:
return m_depthUpperThreshold; return -m_depthUpperThreshold;
case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE:
case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE:
default: default:
return -sceneRadius; return upperGridLimit;
} }
} }
@ -358,7 +358,7 @@ RimIntersectionFilterEnum RimExtrudedCurveIntersection::depthFilterType() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
double RimExtrudedCurveIntersection::lowerFilterDepth( double sceneRadius ) const double RimExtrudedCurveIntersection::lowerFilterDepth( double lowerGridLimit ) const
{ {
if ( m_depthThresholdOverridden ) if ( m_depthThresholdOverridden )
{ {
@ -366,12 +366,12 @@ double RimExtrudedCurveIntersection::lowerFilterDepth( double sceneRadius ) cons
{ {
case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE:
case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN:
return m_collectionLowerThreshold; return -m_collectionLowerThreshold;
case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW:
case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE:
default: default:
return sceneRadius; return lowerGridLimit;
} }
} }
@ -379,12 +379,12 @@ double RimExtrudedCurveIntersection::lowerFilterDepth( double sceneRadius ) cons
{ {
case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE:
case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN:
return m_depthLowerThreshold; return -m_depthLowerThreshold;
case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW:
case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE:
default: default:
return sceneRadius; return lowerGridLimit;
} }
} }

View File

@ -78,8 +78,8 @@ public:
QString name() const override; QString name() const override;
void setName( const QString& newName ); void setName( const QString& newName );
double upperFilterDepth( double sceneRadius ) const; double upperFilterDepth( double upperGridLimit ) const;
double lowerFilterDepth( double sceneRadius ) const; double lowerFilterDepth( double lowerGridLimit ) const;
RimIntersectionFilterEnum depthFilterType() const; RimIntersectionFilterEnum depthFilterType() const;
void setDepthOverride( bool collectionOverride ); void setDepthOverride( bool collectionOverride );