readWorldTransforms method

void readWorldTransforms(
  1. Pointer<Uint64> ids,
  2. int count,
  3. Pointer<Float> out
)

Reads the world transforms of count objects, by their GameObject.ids at ids, into out: ten 32-bit floats each, the position (x, y, z), the rotation (x, y, z, w) and the scale (x, y, z), as the engine works them out (from its matrices: GameObject.worldTransform's, but for a rotation under an uneven scale). One call however many there are; the moves set since the last send are sent first. Throws an ArgumentError if an id isn't a live object.

Implementation

void readWorldTransforms(Pointer<Uint64> ids, int count, Pointer<Float> out) {
  if (count == 0) return;
  _sendTransforms();
  // Each system reads into its own buffer, the same each time, as a
  // rule: each buffer's cast is kept, since making one each call
  // allocates.
  Pointer<FyTransform>? cast;
  for (var i = 0; i < _manyOuts.length; i++) {
    if (_manyOuts[i].address == out.address) cast = _manyOuts[i];
  }
  if (cast == null) {
    if (_manyOuts.length == 8) _manyOuts.removeAt(0);
    cast = out.cast();
    _manyOuts.add(cast);
  }
  final status = fy_world_transform_get_many(pointer, ids, count, cast);
  if (status == FyStatus.FY_STATUS_NO_OBJECT) {
    throw ArgumentError(fy_last_error().cast<Utf8>().toDartString(), 'ids');
  }
  check(status);
}