jaspreetssethi / sgine

Automatically exported from code.google.com/p/sgine
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

animations runs infinitely when target is filtered #23

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I don't know if it is a real issue or if the developer using sgine is 
responsible for avoiding this situation. I've got a double property that is 
filtered and animated:

import org.sgine.property.animate.LinearNumericAnimator
import org.sgine.property.FilteredProperty
import org.sgine.property.MutableProperty
import org.sgine.property.AnimatingProperty
import org.sgine.property.FilterType

object AnimatingFilterIssue {
  def main(args: Array[String]) {

    val prop = new MutableProperty[Double] 
                   with FilteredProperty[Double] 
                   with AnimatingProperty[Double] 
    {
      animator = new LinearNumericAnimator(1)
      val filter = (alpha: Double) => Math.max(0, Math.min(value, 1))
      val filterType = FilterType.Modify
    }

    prop := 1.5;
    prop.waitForTarget();
    println("finished") //unreachable because animation target was filtered
  }
}

Trying to set the animation target to a value that will be filtered causes the 
animation to run infinitely, as the snippet shows. The reason is obviously that 
the animation target can't be reached.
Changing the filter type to 'Retrieve' behaves equal.

I guess this problem could be a mine field for complex projects.

I work with version 2.8.1, Windows 7.

Original issue reported on code.google.com by teenriot...@googlemail.com on 15 Jan 2012 at 11:36

GoogleCodeExporter commented 8 years ago
Sorry, there was a little mistake in the filter. Correct version:

object AnimatingFilterIssue {
  def main(args: Array[String]) {
    val prop = new MutableProperty[Double] 
                   with FilteredProperty[Double] 
                   with AnimatingProperty[Double] 
    {
      animator = new LinearNumericAnimator(1)
      val filter = (value: Double) => Math.max(0, Math.min(value, 1))
      val filterType = FilterType.Modify
    }    
    prop := 1.5;
    prop.waitForTarget();
    println("finished") //unreachable because animation target was filtered
  }
}

Original comment by teenriot...@googlemail.com on 15 Jan 2012 at 11:43