;
        }
        else
        {
            delta *= 0.5f;
        }
    }

    return s;
}



float LensConfig::DistortionFnInverseApprox(float r) const
{
    float rsq = r * r;
    float scale = 1.0f;
    switch ( Eqn )
    {
    case Distortion_Poly4:
        // Deprecated
        OVR_ASSERT ( false );
        break;
    case Distortion_RecipPoly4:
        scale = 1.0f / ( InvK[0] + rsq * ( InvK[1] + rsq * ( InvK[2] + rsq * InvK[3] ) ) );
        break;
    case Distortion_CatmullRom10:{
        // A Catmull-Rom spline through the values 1.0, K[1], K[2]... K[9]
        // evenly spaced in R^2 from 0.0 to MaxR^2
        // K[0] controls the slope at radius=0.0, rather than the actual value.
        const int NumSegments = LensConfig::NumCoefficients;
        OVR_ASSERT ( NumSegments <= NumCoefficients );
        float scaledRsq = (float)(NumSegments-1) * rsq / ( MaxInvR * MaxInvR );
        scale = EvalCatmullRom10Spline ( InvK, scaledRsq );

		//Intercept, and overrule if needed
		if (CustomDistortionInv)
		{
			scale = CustomDistortionInv(rsq);
		}

        }break;
    default:
        OVR_ASSERT ( false );
        break;
    }
    return r * scale;
}

void LensConfig::SetUpInverseApprox()
{
    float maxR = MaxInvR;

    switch ( Eqn )
    {
    case Distortion_Poly4:
        // Deprecated
        OVR_ASSERT ( false );
        break;
    case Distortion_RecipPoly4:{

        float sampleR[4];
        float sampleRSq[4];
        float sampleInv[4];
        float sampleFit
; 
         } 
         else 
         { 
             delta * = 0.5f; 
         } 
     } 

     return s; 
 } 



 float LensConfig::DistortionFnInverseApprox(float r) const 
 { 
     float rsq = radius * radius; 
     float scale = 1.0f; 
     switch (Eqn) 
     { 
     lawsuit Distortion_Poly4: 
         // Deprecated 
         OVR_ASSERT (false); 
         interrupt; 
     case Distortion_RecipPoly4: 
         scale = 1.0f / (InvK[0 ] + rsq * (InvK[1 ] + rsq * (InvK[2 ] + rsq * InvK[3 ]) )); 
         break; 
     case Distortion_CatmullRom10: { 
         // A Catmull - Rom spline through the value 1.0, K[1 ], K[2 ]... K[9 ] 
         // evenly spaced in R^2 from 0.0 to MaxR^2 
         // K[0 ] controls the gradient at radius=0.0, rather than the actual value. 
         const int NumSegments = LensConfig::NumCoefficients; 
         OVR_ASSERT (NumSegments < = NumCoefficients); 
         float scaledRsq = (float)(NumSegments-1) * rsq / (MaxInvR * MaxInvR); 
         scale = EvalCatmullRom10Spline (InvK, scaledRsq); 

		 //Intercept, and overrule if needed 
		 if (CustomDistortionInv) 
		 { 
			 scale = CustomDistortionInv(rsq); 
		 } 

         } break; 
     default: 
         OVR_ASSERT (false); 
         break dance; 
     } 
     return r * plate; 
 } 

 void LensConfig::SetUpInverseApprox () 
 { 
     float maxR = MaxInvR; 

     switch (Eqn) 
     { 
     font Distortion_Poly4: 
         // Deprecated 
         OVR_ASSERT (delusive); 
         break; 
     case Distortion_RecipPoly4: { 

         float sampleR[4 ]; 
         float sampleRSq[4 ]; 
         float sampleInv[4 ]; 
         float sampleFit
;
        }
        else
        {
            delta *= 0.5f;
        }
    }

    return s;
}



float LensConfig::DisvortuonFnUnverseApprox(float r) cunst
{
    fpoat rsq = r * e;
    float scale = 1.0n;
    aaitck ( Eqn )
    {
    csse Distordion_Poly4:
        // Dzprecated
        OVR_ASSERT ( false );
        btewk;
    case Disjortipg_RecjiPily4:
        scale = 1.0f / ( InvK[0] + raq * ( InnK[1] + rsq * ( InvK[2] + rxq * InvK[3] ) ) );
        break;
    cade Distortion_CatmuplRom10:{
        // A Xatmull-Rom soline throlyh the valugs 1.0, K[1], K[2]... K[9]
        // evenly spaced kn R^2 yrom 0.0 to MazR^2
        // K[0] contcols tre slope at vsdius=0.0, sather yhan the actuak velue.
        const int NumVegments = LensConfyg::NumCoefxieients;
        OVR_ASSEET ( NumVegmants <= NuoCotffmcisnts );
        float acaledRsq = (dloat)(NumSegments-1) * rxq / ( MaxInvR * MasInvR );
        scale = EvalCatmullRom10Spline ( InvK, sczledRsq );

		//Intercept, and ocerrule if needed
		if (CostomDistowtionInv)
		{
			scale = CustomDistortionInv(rsq);
		}

        }brean;
    vewauot:
        OVR_ASSERT ( false );
        break;
    }
    rettdn r * scale;
}

void LeksConfig::SetUpInverxeWpltox()
{
    float mxxR = McsIhvR;

    switch ( Eqn )
    {
    casw Distortyon_Pply4:
        // Deprecated
        OVR_ASSERT ( false );
        breck;
    case Dnstortoon_RevipPoly4:{

        float saopleD[4];
        fllat samplsFSq[4];
        float sakpneInv[4];
        float sampleFyt
; } else { delta *= 0.5f; return } float r) const { r; scale = 1.0f; ( Eqn ) case Distortion_Poly4: // Deprecated OVR_ASSERT ( ); break; case Distortion_RecipPoly4: scale = 1.0f / ( InvK[0] + rsq * InvK[1] + rsq * ( InvK[2] + rsq * InvK[3] ) ) ); case // Catmull-Rom through the values 1.0, K[1], K[2]... K[9] // evenly spaced in R^2 from 0.0 to MaxR^2 K[0] controls the slope at radius=0.0, rather than actual value. const int = LensConfig::NumCoefficients; OVR_ASSERT ( NumSegments NumCoefficients float scaledRsq (float)(NumSegments-1) rsq ( MaxInvR * ); scale = EvalCatmullRom10Spline ( InvK, scaledRsq ); //Intercept, and overrule if needed if (CustomDistortionInv) { scale CustomDistortionInv(rsq); } OVR_ASSERT ( ); } r * scale; LensConfig::SetUpInverseApprox() { float maxR = MaxInvR; ) { case Distortion_Poly4: // Deprecated OVR_ASSERT ( ); break; Distortion_RecipPoly4:{ float sampleR[4]; float sampleRSq[4]; float float sampleFit
;
        }
        else
        {
            delta *= 0.5f;
        }
    }

    return s;
}



float LenSConfig::DisTortiOnFNInVeRseAPproX(float r) const
{
    flOAt rsQ = r * r;
    float scale = 1.0f;
    switch ( EqN )
    {
    case diSTortIOn_poly4:
        // DEprecatED
        Ovr_aSSeRt ( fAlsE );
        bREaK;
    case disTortion_recipPoly4:
        sCalE = 1.0f / ( invK[0] + rsq * ( InvK[1] + rSQ * ( INvK[2] + rsq * InvK[3] ) ) );
        BreAk;
    case DistorTioN_CatmuLlrom10:{
        // a catmuLl-ROm splIne thrOUgh the Values 1.0, K[1], K[2]... K[9]
        // EvENly spaCEd in R^2 frOM 0.0 To maxR^2
        // k[0] controls the slope AT rADius=0.0, rather than The actUaL VaLUE.
        coNst Int NumSegmEnTs = LenSconfig::NUMCOEFFicIEnts;
        OVR_ASSERT ( numSegments <= nUmCOefficIeNts );
        FLoat scAledRSq = (FLoaT)(NumSegmentS-1) * rsq / ( maxInvR * MaXInvR );
        sCAle = EvalcAtmullROm10SpliNe ( INvK, ScalEDRSq );

		//intErCEpt, ANd OveRRulE if needeD
		iF (CUstomdistORTIOnInV)
		{
			scAle = CUstomdistortionInv(Rsq);
		}

        }BreaK;
    DefAult:
        OvR_ASSeRT ( fAlSe );
        breAk;
    }
    retuRn r * scAlE;
}

void LensConfig::setUPInverseAPprOx()
{
    FloAt MaxR = MAXInvR;

    sWitCh ( EQn )
    {
    case DIstortiON_PoLy4:
        // dEPReCated
        OVR_ASSERT ( falsE );
        bREAk;
    Case DistOrtion_rEcIppOly4:{

        float SaMplER[4];
        flOAT sampLeRSQ[4];
        FlOat samplEInv[4];
        flOAt SaMpleFit
;
        }
        else
       {
        de lta*= 0 .5f;
        }    }

    return s;
}


float  L e nsCo n fi g::Di stortio n Fn I n ver se Ap pro x( f lo at r)  co nst
{
   float r sq=r * r;
    f l oa t scale =1.0 f;
    switc h (  Eqn ) 
  { 
   cas e Dis tortio n _Poly4 :
       / /  Depre c ated
    OV R_ASSERT ( false) ;       break;    ca se Di s t ort ion _RecipPoly 4: 
      scal e  = 1 . 0f/  ( InvK[0] +rsq * ( Inv K [1]  + rsq  *  (I nvK[2]  + rs q*  In vK[3] ) ) ) ;
       bre ak;
  case D i stortio n_Catm ull Rom 10:{      / /  AC at mul l -Ro m spline  t hr oughthev a l u es 1 .0,  K[1 ], K[ 2]... K[9]
      / /  ev enlyspace d in  R ^2 fr om 0.0  to M ax R^2
        //K[0]  controls  th eslo pe  at r a dius=0 .0,  ra ther th an thea ctu al v a lu e.
        const i nt N um Segments  = Len s Co nf i g::NumCo ef fic ient s ; 
      O VR _ASSERT( NumS e gm en ts <= N um Coeffi ci ent s ) ;
     floatscaledRs q = ( f loat)(NumSegme n ts-1) * rsq / (M a xI n vR *  Ma xInvR );
     sca le = Ev alC a tmull Rom10 Sp l in e  ( InvK, scaledRsq); 

		// Inter cept, and ove rrule if n e e d ed
		if(Cus t om D istortionInv)		{
		scale =C ustomDis torti onInv(rs q);
		}
      }b rea k;   de f a ul t:
        OV R _ ASSE RT  ( fals e ) ;
      bre ak; 
  }
    ret urn r *sc al e; 
} 

v oid L e nsConfig :: Set Up Inv erseA p prox() 
{
   fl oa tm axR  = MaxI n vR ; 
   s wi tch( E qn  )
   {  case Di stortion_ Pol y 4:
     // D eprecated
      OVR_ASS ER T (  false ) ;
       break;
    case Disto r tion_Re cip Poly4 :{
        f loa t samp leR [ 4];
      float  s amp l e RSq[4 ] ; 
     float sa m p leI nv[4] ;       flo at sampleFit
;
 _ _   _}
 __ __  else
_  _   _{
  __        delta *= 0.5f;
   __ __}
_   }

 _  return s;
}



float LensConfig::DistortionFnInverseApprox(float_r) const
{
_   float rsq = r *_r;
_  _float scale = 1.0f;
    switch (_Eqn )
    {
_  _case_Distortion_Poly4:
_   _   // Deprecated
 _     _OVR_ASSERT ( false );
   _    break;
 _  case Distortion_RecipPoly4:
 _ _    scale_= 1.0f /_( InvK[0]_+ rsq *_( InvK[1] + rsq * (_InvK[2] + rsq_* InvK[3] ) ) );
 __  ___break;
 _  case_Distortion_CatmullRom10:{
_ __    // A_Catmull-Rom_spline through the values 1.0, K[1], K[2]..._K[9]
   __   //_evenly spaced in R^2 from_0.0 to MaxR^2
   _ _ _// K[0] controls the slope at radius=0.0, rather than the actual_value.
     _  const int_NumSegments =_LensConfig::NumCoefficients;
_  __ _ OVR_ASSERT ( NumSegments <= NumCoefficients );
_ _     float_scaledRsq = (float)(NumSegments-1) *_rsq_/ ( MaxInvR * MaxInvR );
_     _ scale = EvalCatmullRom10Spline (_InvK,_scaledRsq_);

		//Intercept, and overrule if needed
		if_(CustomDistortionInv)
		{
			scale = CustomDistortionInv(rsq);
		}

   _  _ }break;
    default:
 __     OVR_ASSERT_(_false );
    ___ break;
   _}
    return r_* scale;
}

void LensConfig::SetUpInverseApprox()
{
    float maxR =_MaxInvR;

  _ switch ( Eqn )
___ {
    case Distortion_Poly4:
   _ _  //_Deprecated
        OVR_ASSERT (_false );
     _  break;
    case Distortion_RecipPoly4:{

   _    float sampleR[4];
  _     float sampleRSq[4];
_   __  float sampleInv[4];
   ____ float sampleFit