Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Software License Agreement (BSD License) | ||
3 | * | ||
4 | * Copyright (c) 2021-2022, CNRS | ||
5 | * Author: Louis Montaut | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * * Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * * Redistributions in binary form must reproduce the above | ||
15 | * copyright notice, this list of conditions and the following | ||
16 | * disclaimer in the documentation and/or other materials provided | ||
17 | * with the distribution. | ||
18 | * * Neither the name of Open Source Robotics Foundation nor the names of its | ||
19 | * contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
28 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
32 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
33 | * POSSIBILITY OF SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | #include "coal/math/transform.h" | ||
37 | #include "coal/shape/geometric_shapes.h" | ||
38 | |||
39 | #include "coal/internal/shape_shape_func.h" | ||
40 | #include "../narrowphase/details.h" | ||
41 | |||
42 | #include "coal/tracy.hh" | ||
43 | |||
44 | namespace coal { | ||
45 | struct GJKSolver; | ||
46 | |||
47 | namespace internal { | ||
48 | template <> | ||
49 | 449 | Scalar ShapeShapeDistance<Sphere, Capsule>( | |
50 | const CollisionGeometry* o1, const Transform3s& tf1, | ||
51 | const CollisionGeometry* o2, const Transform3s& tf2, const GJKSolver*, | ||
52 | const bool, Vec3s& p1, Vec3s& p2, Vec3s& normal) { | ||
53 | COAL_TRACY_ZONE_SCOPED_N( | ||
54 | "coal::internal::ShapeShapeDistance<Sphere, Capsule>"); | ||
55 | 449 | const Sphere& s1 = static_cast<const Sphere&>(*o1); | |
56 | 449 | const Capsule& s2 = static_cast<const Capsule&>(*o2); | |
57 | 449 | return details::sphereCapsuleDistance(s1, tf1, s2, tf2, p1, p2, normal); | |
58 | } | ||
59 | |||
60 | template <> | ||
61 | 432 | Scalar ShapeShapeDistance<Capsule, Sphere>( | |
62 | const CollisionGeometry* o1, const Transform3s& tf1, | ||
63 | const CollisionGeometry* o2, const Transform3s& tf2, const GJKSolver*, | ||
64 | const bool, Vec3s& p1, Vec3s& p2, Vec3s& normal) { | ||
65 | COAL_TRACY_ZONE_SCOPED_N( | ||
66 | "coal::internal::ShapeShapeDistance<Capsule, Sphere>"); | ||
67 | 432 | const Capsule& s1 = static_cast<const Capsule&>(*o1); | |
68 | 432 | const Sphere& s2 = static_cast<const Sphere&>(*o2); | |
69 | const Scalar distance = | ||
70 | 432 | details::sphereCapsuleDistance(s2, tf2, s1, tf1, p2, p1, normal); | |
71 |
2/4✓ Branch 1 taken 432 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 432 times.
✗ Branch 5 not taken.
|
432 | normal = -normal; |
72 | 432 | return distance; | |
73 | } | ||
74 | |||
75 | } // namespace internal | ||
76 | |||
77 | } // namespace coal | ||
78 |