void computeAverageP ( Cache cache ) { float [ ] weights = cache . weights . data ; cache . aveP . set ( 0 , 0 ) ; for ( int i = 0 ; i < controls . size ( ) ; i ++ ) { Control c = controls . get ( i ) ; float w = weights [ i ] ; cache . aveP . x += c . p . x * w ; cache . aveP . y += c . p . y * w ; } cache . aveP . x /= cache . totalWeight ; cache . aveP . y /= cache . totalWeight ; }
Computes the average P given the weights at this cached point