BasicInterpolator.cpp 730 B

12345678910111213141516171819202122232425
  1. #include "BasicInterpolator.h"
  2. #include "Block.h"
  3. Framework::Either<Block*, int> BasicInterpolator::interpolateBlocks( Framework::Either<Block*, int> a, Framework::Either<Block*, int> b, double aWeight, double bWeight, Noise* zNoise )
  4. {
  5. if( aWeight < bWeight )
  6. return interpolateBlocks( b, a, bWeight, aWeight, zNoise );
  7. double score = bWeight / aWeight;
  8. if( score < 0.8 )
  9. {
  10. if( b.isA() )
  11. ((Block*)b)->release();
  12. return a;
  13. }
  14. score = (score - 0.8) * 5;
  15. if( score < zNoise->getNoise( (score + 60) * 5, 100, 50 ) )
  16. {
  17. if( b.isA() )
  18. ((Block*)b)->release();
  19. return a;
  20. }
  21. if( a.isA() )
  22. ((Block*)a)->release();
  23. return b;
  24. }