/// Evolver Copyright 2000, Morgan McGuire
/// matrix@alum.mit.edu   http://graphics3d.com/matrix
/**
 * Morphs between previous and next chunks.
 */
class MorphChunk extends AnimationChunk
{
  // The morph expression (recomputed as needed)
  private ELExpression expression = null;

  public ChunkDisplay getDisplay(AnimationEditor editor)
  {
    return new MorphChunkDisplay(editor);
  }

  public ELExpression getExpression()
  {
    return expression;
  }

  /**
   * Call this whenever one of the neighbors changes
   */
  public void invalidateExpression()
  {
    expression = null;
  }

  /**
   * Computes the morph expression, *if* it is invalid.  a and b are the neighbors.
   */
  public void computeExpression(ELExpression a, ELExpression b, GeneticParameters gp) 
  {
    if (expression == null) {
      expression = gp.createGeneticMorphExpression(a, b);
    }
  }

  public String unparse()
  {
    return 
      "MorphChunk: " +
      "duration = " + duration + "\n";
  }
}
