debugLines method

  1. @override
Float32List? debugLines({
  1. bool joints = false,
})
override

Every body (and joint, when joints) as lines, seven floats each: x1 y1 z1 x2 y2 z2, then a colour (0xAARRGGBB) stored in the float's bits (read it with ByteData.view(lines.buffer).getUint32(…, Endian.host)). Null when the backend cannot draw (Jolt outside its dev flavour).

Implementation

@override
Float32List? debugLines({bool joints = false}) {
  if (_gone || !jj_has_debug_renderer()) return null;
  final flags = joints ? 1 : 0;
  final total = jj_debug_lines(handle, flags, nullptr, 0);
  if (total <= 0) return Float32List(0);
  return using((arena) {
    final out = arena<Float>(total * JJ_DEBUG_LINE_FLOATS);
    final n = jj_debug_lines(handle, flags, out, total);
    final count = n < total ? n : total;
    // Copied as bytes: a colour's bits must not pass through a double.
    final bytes = Uint8List.fromList(
      out.cast<Uint8>().asTypedList(count * JJ_DEBUG_LINE_FLOATS * 4),
    );
    return bytes.buffer.asFloat32List();
  });
}