Commit b5112d62 authored by Alexander Wiebel's avatar Alexander Wiebel

[REFAC] extracted function for compositing

parent 57ad80c3
......@@ -574,6 +574,25 @@ double WMPickingDVR::getTFAlpha( const double scalar ) const
return color.getAlpha();
}
double WMPickingDVR::compositingStep( double accAlpha, const double currentAlpha )
{
double currentAlphaCorrected;
if( m_opacityCorrectionEnabled->get( true ) )
{
const double defaultNumberOfSteps = 128.0;
float relativeSampleDistance = defaultNumberOfSteps / m_sampleSteps->get();
currentAlphaCorrected = 1.0 - pow( 1.0 - currentAlpha, relativeSampleDistance );
}
else
{
currentAlphaCorrected = currentAlpha;
}
accAlpha = currentAlphaCorrected + ( accAlpha - currentAlphaCorrected * accAlpha );
return accAlpha;
}
WPosition WMPickingDVR::getPickedDVRPosition( std::string pickingMode, bool* pickingSuccess )
{
......@@ -597,22 +616,7 @@ WPosition WMPickingDVR::getPickedDVRPosition( std::string pickingMode, bool* pi
for( unsigned int i = 0; i < samples.size(); i++ )
{
const double currentAlpha = getTFAlpha( samples[i].first );
double currentAlphaCorrected;
if( m_opacityCorrectionEnabled->get( true ) )
{
const double defaultNumberOfSteps = 128.0;
float relativeSampleDistance = defaultNumberOfSteps / m_sampleSteps->get();
currentAlphaCorrected = 1.0 - pow( 1.0 - currentAlpha, relativeSampleDistance );
}
else
{
currentAlphaCorrected = currentAlpha;
}
accAlpha = currentAlphaCorrected + ( accAlpha - currentAlphaCorrected * accAlpha );
accAlpha = compositingStep( accAlpha, currentAlpha );
if( pickingMode == WMPICKINGDVR_MAX_INT )
{
......
......@@ -160,6 +160,16 @@ private:
*/
double getTFAlpha( const double scalar ) const;
/**
* Perform front to back compositing.
*
* \param accAlpha Opacity accumulated until this step.
* \param currentAlpha Opacity obtained from data value at this step.
*
* \return New accumulated opacity.
*/
double compositingStep( const double accAlpha, double currentAlpha );
/**
* Compute the position picked in the DVR
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment