Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
typed-geometry
Commits
6fe09f9f
Commit
6fe09f9f
authored
Feb 03, 2021
by
Aaron Grabowy
Browse files
Added intersects aabb + boundary
parent
a3ddba2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/typed-geometry/functions/objects/intersection.hh
View file @
6fe09f9f
...
...
@@ -233,12 +233,6 @@ template <int D, class ScalarT, class Obj>
{
return
intersects
(
obj
,
b
);
}
// Explicit intersects aabb aabb to prevent infinite recursion
template
<
int
D
,
class
ScalarT
>
[[
nodiscard
]]
constexpr
bool
intersects
(
aabb
<
D
,
ScalarT
>
const
&
a
,
aabb
<
D
,
ScalarT
>
const
&
b
)
{
return
intersection
(
a
,
b
).
has_value
();
}
// if a value-typed intersection parameter is available and applicable, use that
template
<
class
A
,
class
B
>
...
...
@@ -1215,6 +1209,30 @@ template <int D, class ScalarT>
return
shadow
>=
dist
;
}
template
<
int
D
,
class
ScalarT
>
[[
nodiscard
]]
constexpr
bool
intersects
(
aabb
<
D
,
ScalarT
>
const
&
a
,
aabb
<
D
,
ScalarT
>
const
&
b
)
{
for
(
auto
i
=
0
;
i
<
D
;
++
i
)
{
if
(
b
.
max
[
i
]
<
a
.
min
[
i
]
||
a
.
max
[
i
]
<
b
.
min
[
i
])
return
false
;
}
return
true
;
}
template
<
int
D
,
class
ScalarT
>
[[
nodiscard
]]
constexpr
bool
intersects
(
aabb_boundary
<
D
,
ScalarT
>
const
&
a
,
aabb
<
D
,
ScalarT
>
const
&
b
)
{
auto
contained
=
true
;
for
(
auto
i
=
0
;
i
<
D
;
++
i
)
{
if
(
b
.
max
[
i
]
<
a
.
min
[
i
]
||
a
.
max
[
i
]
<
b
.
min
[
i
])
return
false
;
contained
=
contained
&&
a
.
min
[
i
]
<
b
.
min
[
i
]
&&
b
.
max
[
i
]
<
a
.
max
[
i
];
}
return
!
contained
;
}
template
<
int
D
,
class
ScalarT
>
[[
nodiscard
]]
constexpr
bool
intersects
(
sphere
<
D
,
ScalarT
>
const
&
a
,
aabb
<
D
,
ScalarT
>
const
&
b
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment