raycast method

  1. @override
bool raycast(
  1. RayCastOutput output,
  2. RayCastInput input,
  3. Transform xf,
  4. int childIndex,
)
override

Cast a ray against a child shape.

output is the ray-cast results. input the ray-cast input parameters. transform to be applied to the shape. childIndex the child shape index Returns true if the child shape is hit.

Implementation

@override
bool raycast(
  RayCastOutput output,
  RayCastInput input,
  Transform xf,
  int childIndex,
) {
  assert(childIndex < vertexCount);

  final edgeShape = EdgeShape();

  final i1 = childIndex;
  var i2 = childIndex + 1;
  if (i2 == vertexCount) {
    i2 = 0;
  }
  final v = vertices[i1];
  edgeShape.vertex1.x = v.x;
  edgeShape.vertex1.y = v.y;
  final v1 = vertices[i2];
  edgeShape.vertex2.x = v1.x;
  edgeShape.vertex2.y = v1.y;

  return edgeShape.raycast(output, input, xf, 0);
}