apply method

void apply(
  1. dynamic accuIndex
)

Apply the state of buffer accu[i] to the binding when accus differ.

Implementation

/// binding when accus differ.
void apply(accuIndex) {
  final stride = valueSize,
      buffer = this.buffer,
      offset = accuIndex * stride + stride,
      weight = cumulativeWeight,
      weightAdditive = cumulativeWeightAdditive,
      binding = this.binding;

  cumulativeWeight = 0;
  cumulativeWeightAdditive = 0;

  if (weight < 1) {
    // accuN := accuN + original * ( 1 - cumulativeWeight )

    final originalValueOffset = stride * _origIndex;

    _mixBufferRegion(
      buffer,
      offset,
      originalValueOffset,
      1 - weight.toDouble(),
      stride
    );
  }

  if (weightAdditive > 0) {
    // accuN := accuN + additive accuN
    _mixBufferRegionAdditive(buffer, offset, _addIndex * stride, 1.0, stride);
  }

  for (int i = stride, e = stride + stride; i != e; ++i) {
    if (buffer[i] != buffer[i + stride]) {
      // value has changed -> update scene graph
      binding.setValue(buffer, offset);
      break;
    }
  }
}