diff --git a/.clang-format b/.clang-format index 7dc18ab95..0f8e3254c 100644 --- a/.clang-format +++ b/.clang-format @@ -8,7 +8,32 @@ BinPackParameters: false AllowAllParametersOfDeclarationOnNextLine: true AlignAfterOpenBracket: AlwaysBreak BreakBeforeBinaryOperators: NonAssignment -SortIncludes: false +SortIncludes: true CommentPragmas: '^@.+' BreakStringLiterals: false PackConstructorInitializers: CurrentLine +# Regroup includes with a priority system +IncludeBlocks: Regroup +IncludeCategories: + # by default, the main header of a cpp will get priority 0 + # regex here are sorted by search pattern, not by sort priority + - Regex: "^" # this libraries + Priority: 2 # internal library group + SortPriority: 2 + CaseSensitive: true + - Regex: "^" # this libraries + Priority: 2 # internal library group + SortPriority: 3 + CaseSensitive: true + - Regex: "^<(.*\\.h[px]*)|(Eigen\/.*)>" + Priority: 4 # libraries (because they end in .h) + SortPriority: 4 + CaseSensitive: false + - Regex: "^<.*" + Priority: 5 # system (without .h, because that is captured by the other group) + SortPriority: 5 + CaseSensitive: false + - Regex: ".*" # catch-all for internal files + Priority: 1 # internal file group + SortPriority: 1 + CaseSensitive: true \ No newline at end of file diff --git a/python/.clang-format b/python/.clang-format new file mode 100644 index 000000000..81b665b3c --- /dev/null +++ b/python/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: InheritParentConfig +SortIncludes: false \ No newline at end of file diff --git a/python/src/utils/eigen_ext.cpp b/python/src/utils/eigen_ext.cpp index 803891557..029d23732 100644 --- a/python/src/utils/eigen_ext.cpp +++ b/python/src/utils/eigen_ext.cpp @@ -9,9 +9,11 @@ void define_eigen_ext(py::module_& m) { m.def( "project_to_pd", + // clang-format off &project_to_pd< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor | Eigen::AutoAlign, Eigen::Dynamic, Eigen::Dynamic>, + // clang-format on R"ipc_Qu8mg5v7( Matrix projection onto positive definite cone @@ -35,9 +37,11 @@ void define_eigen_ext(py::module_& m) m.def( "project_to_psd", + // clang-format off &project_to_psd< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor | Eigen::AutoAlign, Eigen::Dynamic, Eigen::Dynamic>, + // clang-format on R"ipc_Qu8mg5v7( Matrix projection onto positive semi-definite cone diff --git a/src/ipc/broad_phase/aabb.cpp b/src/ipc/broad_phase/aabb.cpp index f276536c5..d9d0bd556 100644 --- a/src/ipc/broad_phase/aabb.cpp +++ b/src/ipc/broad_phase/aabb.cpp @@ -1,7 +1,7 @@ #include "aabb.hpp" -#include #include +#include #include diff --git a/src/ipc/broad_phase/broad_phase.cpp b/src/ipc/broad_phase/broad_phase.cpp index 8d10fa797..e816006d5 100644 --- a/src/ipc/broad_phase/broad_phase.cpp +++ b/src/ipc/broad_phase/broad_phase.cpp @@ -1,15 +1,14 @@ #include "broad_phase.hpp" +#include #include #include -#include #include +#include #include #include #include -#include - namespace ipc { void BroadPhase::build( diff --git a/src/ipc/broad_phase/brute_force.cpp b/src/ipc/broad_phase/brute_force.cpp index 0b3150b05..e6bed7560 100644 --- a/src/ipc/broad_phase/brute_force.cpp +++ b/src/ipc/broad_phase/brute_force.cpp @@ -2,9 +2,9 @@ #include +#include #include #include -#include #include // std::min/max diff --git a/src/ipc/broad_phase/bvh.cpp b/src/ipc/broad_phase/bvh.cpp index 4ce4c2a0f..860b75671 100644 --- a/src/ipc/broad_phase/bvh.cpp +++ b/src/ipc/broad_phase/bvh.cpp @@ -2,9 +2,9 @@ #include -#include #include #include +#include using namespace std::placeholders; diff --git a/src/ipc/broad_phase/hash_grid.cpp b/src/ipc/broad_phase/hash_grid.cpp index 5aa08513a..425e1ef56 100644 --- a/src/ipc/broad_phase/hash_grid.cpp +++ b/src/ipc/broad_phase/hash_grid.cpp @@ -1,11 +1,11 @@ #include "hash_grid.hpp" #include -#include #include +#include -#include #include +#include #include #include diff --git a/src/ipc/broad_phase/spatial_hash.cpp b/src/ipc/broad_phase/spatial_hash.cpp index f7be36cc2..0382ca97f 100644 --- a/src/ipc/broad_phase/spatial_hash.cpp +++ b/src/ipc/broad_phase/spatial_hash.cpp @@ -2,12 +2,11 @@ // Originally created by Minchen Li. #include "spatial_hash.hpp" -#include +#include #include +#include #include -#include - #include #include #include diff --git a/src/ipc/broad_phase/spatial_hash.hpp b/src/ipc/broad_phase/spatial_hash.hpp index 3f6192517..8ddcc094a 100644 --- a/src/ipc/broad_phase/spatial_hash.hpp +++ b/src/ipc/broad_phase/spatial_hash.hpp @@ -3,8 +3,8 @@ #pragma once #include -#include #include +#include #include diff --git a/src/ipc/broad_phase/sweep_and_tiniest_queue.hpp b/src/ipc/broad_phase/sweep_and_tiniest_queue.hpp index b8b44ed91..23fe69821 100644 --- a/src/ipc/broad_phase/sweep_and_tiniest_queue.hpp +++ b/src/ipc/broad_phase/sweep_and_tiniest_queue.hpp @@ -5,6 +5,7 @@ #ifdef IPC_TOOLKIT_WITH_CUDA #include + #include namespace ipc { diff --git a/src/ipc/candidates/candidates.cpp b/src/ipc/candidates/candidates.cpp index ca3519839..5a0f9cd8b 100644 --- a/src/ipc/candidates/candidates.cpp +++ b/src/ipc/candidates/candidates.cpp @@ -1,17 +1,16 @@ #include "candidates.hpp" +#include #include -#include #include - -#include +#include #include -#include #include -#include +#include #include +#include namespace ipc { diff --git a/src/ipc/candidates/candidates.hpp b/src/ipc/candidates/candidates.hpp index 2173abd27..41088cad6 100644 --- a/src/ipc/candidates/candidates.hpp +++ b/src/ipc/candidates/candidates.hpp @@ -1,10 +1,10 @@ #pragma once #include -#include -#include #include +#include #include +#include #include diff --git a/src/ipc/candidates/continuous_collision_candidate.hpp b/src/ipc/candidates/continuous_collision_candidate.hpp index 767239eae..2acf1552e 100644 --- a/src/ipc/candidates/continuous_collision_candidate.hpp +++ b/src/ipc/candidates/continuous_collision_candidate.hpp @@ -1,10 +1,10 @@ #pragma once -#include #include +#include -#include #include +#include namespace ipc { diff --git a/src/ipc/ccd/additive_ccd.cpp b/src/ipc/ccd/additive_ccd.cpp index 6f33adfb6..fe7975433 100644 --- a/src/ipc/ccd/additive_ccd.cpp +++ b/src/ipc/ccd/additive_ccd.cpp @@ -21,10 +21,10 @@ #include "additive_ccd.hpp" -#include +#include #include +#include #include -#include namespace ipc { diff --git a/src/ipc/ccd/inexact_ccd.cpp b/src/ipc/ccd/inexact_ccd.cpp index ef743a0c8..4bd22c690 100644 --- a/src/ipc/ccd/inexact_ccd.cpp +++ b/src/ipc/ccd/inexact_ccd.cpp @@ -3,9 +3,9 @@ #ifdef IPC_TOOLKIT_WITH_INEXACT_CCD #include -#include -#include #include +#include +#include #include #include diff --git a/src/ipc/ccd/nonlinear_ccd.cpp b/src/ipc/ccd/nonlinear_ccd.cpp index c53f6f701..e9f3c3c6f 100644 --- a/src/ipc/ccd/nonlinear_ccd.cpp +++ b/src/ipc/ccd/nonlinear_ccd.cpp @@ -1,9 +1,9 @@ #include "nonlinear_ccd.hpp" #include -#include -#include #include +#include +#include #include #include diff --git a/src/ipc/ccd/nonlinear_ccd.hpp b/src/ipc/ccd/nonlinear_ccd.hpp index 2fc84c334..1c65c9354 100644 --- a/src/ipc/ccd/nonlinear_ccd.hpp +++ b/src/ipc/ccd/nonlinear_ccd.hpp @@ -1,7 +1,6 @@ #pragma once #include - #include #ifdef IPC_TOOLKIT_WITH_FILIB #include diff --git a/src/ipc/ccd/tight_inclusion_ccd.cpp b/src/ipc/ccd/tight_inclusion_ccd.cpp index 9fdc7c784..72175c857 100644 --- a/src/ipc/ccd/tight_inclusion_ccd.cpp +++ b/src/ipc/ccd/tight_inclusion_ccd.cpp @@ -1,9 +1,9 @@ #include "tight_inclusion_ccd.hpp" #include -#include -#include #include +#include +#include #include #include diff --git a/src/ipc/collision_mesh.cpp b/src/ipc/collision_mesh.cpp index 4a116a12d..64e8faf42 100644 --- a/src/ipc/collision_mesh.cpp +++ b/src/ipc/collision_mesh.cpp @@ -1,10 +1,10 @@ #include "collision_mesh.hpp" -#include -#include +#include #include #include -#include +#include +#include namespace ipc { diff --git a/src/ipc/collisions/collisions.cpp b/src/ipc/collisions/collisions.cpp index 6b8a1965f..86e0d9dcc 100644 --- a/src/ipc/collisions/collisions.cpp +++ b/src/ipc/collisions/collisions.cpp @@ -1,18 +1,18 @@ #include "collisions.hpp" #include -#include -#include -#include #include +#include +#include #include +#include #include +#include +#include #include #include #include -#include -#include #include // std::out_of_range diff --git a/src/ipc/collisions/collisions.hpp b/src/ipc/collisions/collisions.hpp index ca8117737..515218b6f 100644 --- a/src/ipc/collisions/collisions.hpp +++ b/src/ipc/collisions/collisions.hpp @@ -1,14 +1,14 @@ #pragma once #include +#include +#include #include -#include -#include #include +#include #include #include -#include -#include +#include #include diff --git a/src/ipc/collisions/collisions_builder.cpp b/src/ipc/collisions/collisions_builder.cpp index 5295e70e4..ed61a1fde 100644 --- a/src/ipc/collisions/collisions_builder.cpp +++ b/src/ipc/collisions/collisions_builder.cpp @@ -1,10 +1,10 @@ #include "collisions_builder.hpp" #include -#include -#include #include #include +#include +#include #include namespace ipc { diff --git a/src/ipc/collisions/collisions_builder.hpp b/src/ipc/collisions/collisions_builder.hpp index 6df686331..1fd07c8ae 100644 --- a/src/ipc/collisions/collisions_builder.hpp +++ b/src/ipc/collisions/collisions_builder.hpp @@ -3,9 +3,8 @@ #include #include -#include - #include +#include namespace ipc { diff --git a/src/ipc/distance/edge_edge.cpp b/src/ipc/distance/edge_edge.cpp index 5b3f6ac82..d64a3bb95 100644 --- a/src/ipc/distance/edge_edge.cpp +++ b/src/ipc/distance/edge_edge.cpp @@ -2,9 +2,9 @@ #include "edge_edge.hpp" -#include -#include #include +#include +#include #include // std::invalid_argument diff --git a/src/ipc/distance/point_plane.cpp b/src/ipc/distance/point_plane.cpp index 0b85280f2..cb16e6436 100644 --- a/src/ipc/distance/point_plane.cpp +++ b/src/ipc/distance/point_plane.cpp @@ -1,6 +1,7 @@ #include "point_plane.hpp" #include + #include namespace ipc { diff --git a/src/ipc/friction/closest_point.cpp b/src/ipc/friction/closest_point.cpp index 26c15c717..b6df8c1e7 100644 --- a/src/ipc/friction/closest_point.cpp +++ b/src/ipc/friction/closest_point.cpp @@ -1,7 +1,7 @@ #include "closest_point.hpp" -#include #include +#include namespace ipc { diff --git a/src/ipc/friction/collisions/edge_edge.cpp b/src/ipc/friction/collisions/edge_edge.cpp index c05dadab8..d5a51a86b 100644 --- a/src/ipc/friction/collisions/edge_edge.cpp +++ b/src/ipc/friction/collisions/edge_edge.cpp @@ -1,9 +1,9 @@ #include "edge_edge.hpp" +#include #include #include #include -#include namespace ipc { diff --git a/src/ipc/friction/collisions/edge_edge.hpp b/src/ipc/friction/collisions/edge_edge.hpp index 1971781f6..4220d7be1 100644 --- a/src/ipc/friction/collisions/edge_edge.hpp +++ b/src/ipc/friction/collisions/edge_edge.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include namespace ipc { diff --git a/src/ipc/friction/collisions/edge_vertex.cpp b/src/ipc/friction/collisions/edge_vertex.cpp index b51ac8ea3..42b37c22a 100644 --- a/src/ipc/friction/collisions/edge_vertex.cpp +++ b/src/ipc/friction/collisions/edge_vertex.cpp @@ -1,9 +1,9 @@ #include "edge_vertex.hpp" +#include #include #include #include -#include namespace ipc { diff --git a/src/ipc/friction/collisions/edge_vertex.hpp b/src/ipc/friction/collisions/edge_vertex.hpp index 89f67c3e8..579ff2792 100644 --- a/src/ipc/friction/collisions/edge_vertex.hpp +++ b/src/ipc/friction/collisions/edge_vertex.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include namespace ipc { diff --git a/src/ipc/friction/collisions/face_vertex.cpp b/src/ipc/friction/collisions/face_vertex.cpp index 8bd6fa1ab..5103d9dcf 100644 --- a/src/ipc/friction/collisions/face_vertex.cpp +++ b/src/ipc/friction/collisions/face_vertex.cpp @@ -1,9 +1,9 @@ #include "face_vertex.hpp" +#include #include #include #include -#include namespace ipc { diff --git a/src/ipc/friction/collisions/face_vertex.hpp b/src/ipc/friction/collisions/face_vertex.hpp index 97e4624b0..f58f10388 100644 --- a/src/ipc/friction/collisions/face_vertex.hpp +++ b/src/ipc/friction/collisions/face_vertex.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include namespace ipc { diff --git a/src/ipc/friction/collisions/friction_collision.cpp b/src/ipc/friction/collisions/friction_collision.cpp index bcb3a5257..7ec4fd962 100644 --- a/src/ipc/friction/collisions/friction_collision.cpp +++ b/src/ipc/friction/collisions/friction_collision.cpp @@ -1,8 +1,7 @@ #include "friction_collision.hpp" -#include - #include +#include #include // std::out_of_range diff --git a/src/ipc/friction/collisions/friction_collision.hpp b/src/ipc/friction/collisions/friction_collision.hpp index cc916d68d..30126997a 100644 --- a/src/ipc/friction/collisions/friction_collision.hpp +++ b/src/ipc/friction/collisions/friction_collision.hpp @@ -1,12 +1,11 @@ #pragma once -#include +#include +#include #include #include +#include #include -#include - -#include namespace ipc { diff --git a/src/ipc/friction/collisions/vertex_vertex.cpp b/src/ipc/friction/collisions/vertex_vertex.cpp index 2f88a8bc7..493e1035f 100644 --- a/src/ipc/friction/collisions/vertex_vertex.cpp +++ b/src/ipc/friction/collisions/vertex_vertex.cpp @@ -1,9 +1,9 @@ #include "vertex_vertex.hpp" +#include #include #include #include -#include namespace ipc { diff --git a/src/ipc/friction/collisions/vertex_vertex.hpp b/src/ipc/friction/collisions/vertex_vertex.hpp index fe24be512..d7e349494 100644 --- a/src/ipc/friction/collisions/vertex_vertex.hpp +++ b/src/ipc/friction/collisions/vertex_vertex.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include namespace ipc { diff --git a/src/ipc/friction/friction_collisions.cpp b/src/ipc/friction/friction_collisions.cpp index 5a1331d52..68d0208e5 100644 --- a/src/ipc/friction/friction_collisions.cpp +++ b/src/ipc/friction/friction_collisions.cpp @@ -3,9 +3,9 @@ #include #include -#include #include #include +#include #include // std::out_of_range diff --git a/src/ipc/friction/friction_collisions.hpp b/src/ipc/friction/friction_collisions.hpp index 12297eeb7..2a32e523b 100644 --- a/src/ipc/friction/friction_collisions.hpp +++ b/src/ipc/friction/friction_collisions.hpp @@ -1,13 +1,12 @@ #pragma once -#include -#include -#include -#include -#include - #include #include +#include +#include +#include +#include +#include #include #include diff --git a/src/ipc/implicits/plane.cpp b/src/ipc/implicits/plane.cpp index 0ae4767f9..0e78444c7 100644 --- a/src/ipc/implicits/plane.cpp +++ b/src/ipc/implicits/plane.cpp @@ -1,10 +1,10 @@ #include "plane.hpp" -#include #include +#include -#include #include +#include namespace ipc { diff --git a/src/ipc/ipc.cpp b/src/ipc/ipc.cpp index 51f5dc61b..7737a3ffb 100644 --- a/src/ipc/ipc.cpp +++ b/src/ipc/ipc.cpp @@ -1,11 +1,10 @@ #include "ipc.hpp" +#include #include #include #include -#include - #ifdef IPC_TOOLKIT_WITH_CUDA #include #endif diff --git a/src/ipc/ipc.hpp b/src/ipc/ipc.hpp index 9c0c2f87a..697b7c688 100644 --- a/src/ipc/ipc.hpp +++ b/src/ipc/ipc.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include #include diff --git a/src/ipc/potentials/barrier_potential.hpp b/src/ipc/potentials/barrier_potential.hpp index 37920c618..939a7b71c 100644 --- a/src/ipc/potentials/barrier_potential.hpp +++ b/src/ipc/potentials/barrier_potential.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include diff --git a/src/ipc/potentials/distance_based_potential.hpp b/src/ipc/potentials/distance_based_potential.hpp index 2ee21369f..150f5cd3b 100644 --- a/src/ipc/potentials/distance_based_potential.hpp +++ b/src/ipc/potentials/distance_based_potential.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include namespace ipc { diff --git a/src/ipc/potentials/friction_potential.hpp b/src/ipc/potentials/friction_potential.hpp index 345d026be..13ad9c185 100644 --- a/src/ipc/potentials/friction_potential.hpp +++ b/src/ipc/potentials/friction_potential.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include namespace ipc { diff --git a/src/ipc/utils/intersection.cpp b/src/ipc/utils/intersection.cpp index c6f991bae..f35b51885 100644 --- a/src/ipc/utils/intersection.cpp +++ b/src/ipc/utils/intersection.cpp @@ -1,11 +1,10 @@ #include "intersection.hpp" -#include #include - -#include +#include #include +#include #ifdef IPC_TOOLKIT_WITH_RATIONAL_INTERSECTION #include diff --git a/src/ipc/utils/interval.hpp b/src/ipc/utils/interval.hpp index 69f1b15af..2943ae8ec 100644 --- a/src/ipc/utils/interval.hpp +++ b/src/ipc/utils/interval.hpp @@ -7,7 +7,6 @@ #include #include - #include namespace filib { diff --git a/src/ipc/utils/merge_thread_local.hpp b/src/ipc/utils/merge_thread_local.hpp index 38363cf46..394df63a1 100644 --- a/src/ipc/utils/merge_thread_local.hpp +++ b/src/ipc/utils/merge_thread_local.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include namespace ipc { diff --git a/src/ipc/utils/save_obj.cpp b/src/ipc/utils/save_obj.cpp index 1f2bfdad5..2e8bf8801 100644 --- a/src/ipc/utils/save_obj.cpp +++ b/src/ipc/utils/save_obj.cpp @@ -1,10 +1,10 @@ #include "save_obj.hpp" -#include -#include #include -#include #include +#include +#include +#include #include namespace ipc { diff --git a/src/ipc/utils/save_obj.hpp b/src/ipc/utils/save_obj.hpp index 006197296..4cd004ae4 100644 --- a/src/ipc/utils/save_obj.hpp +++ b/src/ipc/utils/save_obj.hpp @@ -2,9 +2,9 @@ #include -#include -#include #include +#include +#include namespace ipc { diff --git a/tests/.clang-format b/tests/.clang-format new file mode 100644 index 000000000..81b665b3c --- /dev/null +++ b/tests/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: InheritParentConfig +SortIncludes: false \ No newline at end of file