updateConvexPolyhedronRepresentation method

void updateConvexPolyhedronRepresentation()

Updates the local convex polyhedron representation used for some collisions.

Implementation

void updateConvexPolyhedronRepresentation(){
  final double sx = halfExtents.x;
  final double sy = halfExtents.y;
  final double sz = halfExtents.z;

  List<Vec3> vertices = [
    Vec3(-sx, -sy, -sz),
    Vec3(sx, -sy, -sz),
    Vec3(sx, sy, -sz),
    Vec3(-sx, sy, -sz),
    Vec3(-sx, -sy, sz),
    Vec3(sx, -sy, sz),
    Vec3(sx, sy, sz),
    Vec3(-sx, sy, sz),
  ];

  const faces = [
    [3, 2, 1, 0], // -z
    [4, 5, 6, 7], // +z
    [5, 4, 0, 1], // -y
    [2, 3, 7, 6], // +y
    [0, 4, 7, 3], // -x
    [1, 2, 6, 5], // +x
  ];

  final List<Vec3> axes = [
    Vec3(0, 0, 1),
    Vec3(0, 1, 0),
    Vec3(1, 0, 0)
  ];

  convexPolyhedronRepresentation = ConvexPolyhedron(
    vertices:vertices,
    faces:faces,
    axes:axes,
  );
  convexPolyhedronRepresentation.material = material;
}