3

So I will like to get the following code:

bool hitSphere(
  const Vec3 &center,
  double radius,
  const Vec3 &origin,
  const Vec3 &direction) {
  Vec3 oc = origin - center;
  double a = dot(direction, direction);
  double b = 2.0 * dot(oc, direction);
  double c = dot(oc, oc) - radius * radius;
  double discriminant = b * b - 4 * a * c;
  return discriminant > 0;
}

to get formatted like this by clang format:

bool hitSphere(
  const Vec3 &center,
  double radius,
  const Vec3 &origin,
  const Vec3 &direction
) {
  Vec3 oc = origin - center;
  double a = dot(direction, direction);
  double b = 2.0 * dot(oc, direction);
  double c = dot(oc, oc) - radius * radius;
  double discriminant = b * b - 4 * a * c;
  return discriminant > 0;
}

Notice how before the closing bracket there is a new line now.

I read all the docs of https://clang.llvm.org/docs/ClangFormatStyleOptions.html but I could not find how to do this.

It is even posible what I want?

ellipticaldoor
  • 1,122
  • 11
  • 24

1 Answers1

0

Looks like this is not posible yet but they are working to add this feature

https://reviews.llvm.org/D33029

Will be called DanglingParenthesis

ellipticaldoor
  • 1,122
  • 11
  • 24