Directory: | ./ |
---|---|
File: | python/broadphase/broadphase.cc |
Date: | 2025-04-01 09:23:31 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 41 | 41 | 100.0% |
Branches: | 25 | 50 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Software License Agreement (BSD License) | ||
3 | // | ||
4 | // Copyright (c) 2022 INRIA | ||
5 | // Author: Justin Carpentier | ||
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 CNRS-LAAS. 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 | #include "coal/fwd.hh" | ||
36 | #include "../coal.hh" | ||
37 | #include "../utils/std-pair.hh" | ||
38 | |||
39 | #include "coal/broadphase/broadphase_dynamic_AABB_tree.h" | ||
40 | #include "coal/broadphase/broadphase_dynamic_AABB_tree_array.h" | ||
41 | #include "coal/broadphase/broadphase_bruteforce.h" | ||
42 | #include "coal/broadphase/broadphase_SaP.h" | ||
43 | #include "coal/broadphase/broadphase_SSaP.h" | ||
44 | #include "coal/broadphase/broadphase_interval_tree.h" | ||
45 | #include "coal/broadphase/broadphase_spatialhash.h" | ||
46 | |||
47 | COAL_COMPILER_DIAGNOSTIC_PUSH | ||
48 | COAL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS | ||
49 | #ifdef COAL_HAS_DOXYGEN_AUTODOC | ||
50 | #include "doxygen_autodoc/functions.h" | ||
51 | COAL_COMPILER_DIAGNOSTIC_POP | ||
52 | #include "doxygen_autodoc/coal/broadphase/default_broadphase_callbacks.h" | ||
53 | // #include "doxygen_autodoc/coal/broadphase/broadphase_dynamic_AABB_tree.h" | ||
54 | // #include | ||
55 | //"doxygen_autodoc/coal/broadphase/broadphase_dynamic_AABB_tree_array.h" | ||
56 | // #include "doxygen_autodoc/coal/broadphase/broadphase_bruteforce.h" | ||
57 | // #include "doxygen_autodoc/coal/broadphase/broadphase_SaP.h" | ||
58 | // #include "doxygen_autodoc/coal/broadphase/broadphase_SSaP.h" | ||
59 | // #include "doxygen_autodoc/coal/broadphase/broadphase_interval_tree.h" | ||
60 | // #include "doxygen_autodoc/coal/broadphase/broadphase_spatialhash.h" | ||
61 | #endif | ||
62 | |||
63 | #include "broadphase_callbacks.hh" | ||
64 | #include "broadphase_collision_manager.hh" | ||
65 | |||
66 | using namespace coal; | ||
67 | |||
68 | COAL_COMPILER_DIAGNOSTIC_PUSH | ||
69 | COAL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS | ||
70 | 5 | void exposeBroadPhase() { | |
71 | 5 | CollisionCallBackBaseWrapper::expose(); | |
72 | 5 | DistanceCallBackBaseWrapper::expose(); | |
73 | |||
74 | // CollisionCallBackDefault | ||
75 | 5 | bp::class_<CollisionCallBackDefault, bp::bases<CollisionCallBackBase>>( | |
76 | "CollisionCallBackDefault", bp::no_init) | ||
77 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .def(dv::init<CollisionCallBackDefault>()) |
78 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(CollisionCallBackDefault, data); |
79 | |||
80 | // DistanceCallBackDefault | ||
81 | 5 | bp::class_<DistanceCallBackDefault, bp::bases<DistanceCallBackBase>>( | |
82 | "DistanceCallBackDefault", bp::no_init) | ||
83 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .def(dv::init<DistanceCallBackDefault>()) |
84 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(DistanceCallBackDefault, data); |
85 | |||
86 | // CollisionCallBackCollect | ||
87 | 5 | bp::class_<CollisionCallBackCollect, bp::bases<CollisionCallBackBase>>( | |
88 | "CollisionCallBackCollect", bp::no_init) | ||
89 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .def(dv::init<CollisionCallBackCollect, const size_t>()) |
90 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(CollisionCallBackCollect, numCollisionPairs) |
91 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_CLASS_FUNC2(CollisionCallBackCollect, getCollisionPairs, |
92 | bp::return_value_policy<bp::copy_const_reference>()) | ||
93 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .def(dv::member_func( |
94 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | "exist", (bool(CollisionCallBackCollect::*)( |
95 | const CollisionCallBackCollect::CollisionPair &) const) & | ||
96 | CollisionCallBackCollect::exist)) | ||
97 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .def(dv::member_func("exist", |
98 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 | (bool(CollisionCallBackCollect::*)( |
99 | CollisionObject *, CollisionObject *) const) & | ||
100 | CollisionCallBackCollect::exist)); | ||
101 | |||
102 | 5 | StdPairConverter<CollisionCallBackCollect::CollisionPair>::registration(); | |
103 | |||
104 | 5 | bp::class_<CollisionData>("CollisionData", bp::no_init) | |
105 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .def(dv::init<CollisionData>()) |
106 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(CollisionData, request) |
107 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(CollisionData, result) |
108 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(CollisionData, done) |
109 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(CollisionData, clear); |
110 | |||
111 | 5 | bp::class_<DistanceData>("DistanceData", bp::no_init) | |
112 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .def(dv::init<DistanceData>()) |
113 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(DistanceData, request) |
114 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(DistanceData, result) |
115 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | .DEF_RW_CLASS_ATTRIB(DistanceData, done) |
116 |
2/4✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | .DEF_CLASS_FUNC(DistanceData, clear); |
117 | |||
118 | 5 | BroadPhaseCollisionManagerWrapper::expose(); | |
119 | |||
120 | BroadPhaseCollisionManagerWrapper::exposeDerived< | ||
121 | 5 | DynamicAABBTreeCollisionManager>(); | |
122 | BroadPhaseCollisionManagerWrapper::exposeDerived< | ||
123 | 5 | DynamicAABBTreeArrayCollisionManager>(); | |
124 | BroadPhaseCollisionManagerWrapper::exposeDerived< | ||
125 | 5 | IntervalTreeCollisionManager>(); | |
126 | 5 | BroadPhaseCollisionManagerWrapper::exposeDerived<SSaPCollisionManager>(); | |
127 | 5 | BroadPhaseCollisionManagerWrapper::exposeDerived<SaPCollisionManager>(); | |
128 | 5 | BroadPhaseCollisionManagerWrapper::exposeDerived<NaiveCollisionManager>(); | |
129 | |||
130 | // Specific case of SpatialHashingCollisionManager | ||
131 | { | ||
132 | typedef detail::SimpleHashTable<AABB, CollisionObject *, | ||
133 | detail::SpatialHash> | ||
134 | HashTable; | ||
135 | typedef SpatialHashingCollisionManager<HashTable> Derived; | ||
136 | 5 | bp::class_<Derived, bp::bases<BroadPhaseCollisionManager>>( | |
137 | "SpatialHashingCollisionManager", bp::no_init) | ||
138 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | .def(dv::init<Derived, Scalar, const Vec3s &, const Vec3s &, |
139 | 10 | bp::optional<unsigned int>>()); | |
140 | } | ||
141 | 5 | } | |
142 | COAL_COMPILER_DIAGNOSTIC_POP | ||
143 |