Skip to content
GitLab
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
3e87fe3a
Commit
3e87fe3a
authored
Mar 24, 2021
by
Julian Schakib
Browse files
forward declaration to include functions elsewhere
parent
1be1afde
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/typed-geometry/detail/constructors-fun.hh
View file @
3e87fe3a
...
...
@@ -9,12 +9,14 @@
#include
<typed-geometry/types/objects/box.hh>
#include
<typed-geometry/types/objects/ellipse.hh>
#include
<typed-geometry/types/objects/frustum.hh>
#include
<typed-geometry/types/objects/halfspace.hh>
#include
<typed-geometry/types/objects/line.hh>
#include
<typed-geometry/types/objects/plane.hh>
#include
<typed-geometry/detail/operators/ops_pos.hh>
#include
<typed-geometry/functions/vector/dot.hh>
#include
<typed-geometry/functions/vector/length.hh>
// Header for all constructors that depend on functions
...
...
@@ -63,4 +65,22 @@ constexpr line<D, ScalarT> line<D, ScalarT>::from_points(pos_t a, pos_t b)
{
return
line
(
a
,
normalize
(
b
-
a
));
}
template
<
class
ScalarT
>
constexpr
frustum
<
ScalarT
>::
frustum
(
mat
<
4
,
4
,
ScalarT
>
const
&
m
)
{
// computing planes in order: left, right, bottom, top, near, far
for
(
auto
i
=
0u
;
i
<
3
;
++
i
)
for
(
auto
j
=
0u
;
j
<
2
;
++
j
)
{
// plane parameters from matrix (see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf)
vec4
abcd
;
for
(
auto
k
=
0
;
k
<
4
;
++
k
)
abcd
[
k
]
=
j
==
0
?
m
[
k
][
3
]
+
m
[
k
][
i
]
:
m
[
k
][
3
]
-
m
[
k
][
i
];
auto
n
=
vec3
(
abcd
);
auto
l
=
length
(
n
);
planes
[
2
*
i
+
j
]
=
plane3
(
dir3
(
n
/
l
),
-
abcd
.
w
/
l
);
}
}
}
src/typed-geometry/types/objects/frustum.hh
View file @
3e87fe3a
...
...
@@ -2,10 +2,6 @@
#include
<typed-geometry/feature/assert.hh>
#include
<typed-geometry/functions/swizzling/swizzling-basic.hh>
#include
<typed-geometry/functions/vector/dot.hh>
#include
<typed-geometry/functions/vector/length.hh>
#include
<typed-geometry/functions/vector/normalize.hh>
#include
<typed-geometry/types/scalars/default.hh>
#include
"../pos.hh"
#include
"../vec.hh"
...
...
@@ -36,22 +32,7 @@ struct frustum
}
// extract frustum from a view-projection-matrix (proj * view)
explicit
constexpr
frustum
(
mat
<
4
,
4
,
ScalarT
>
const
&
m
)
{
// computing planes in order: left, right, bottom, top, near, far
for
(
auto
i
=
0u
;
i
<
3
;
++
i
)
for
(
auto
j
=
0u
;
j
<
2
;
++
j
)
{
// plane parameters from matrix (see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf)
vec4
abcd
;
for
(
auto
k
=
0
;
k
<
4
;
++
k
)
abcd
[
k
]
=
j
==
0
?
m
[
k
][
3
]
+
m
[
k
][
i
]
:
m
[
k
][
3
]
-
m
[
k
][
i
];
auto
n
=
vec3
(
abcd
);
auto
l
=
length
(
n
);
planes
[
2
*
i
+
j
]
=
plane3
(
dir3
(
n
/
l
),
-
abcd
.
w
/
l
);
}
}
constexpr
frustum
(
mat
<
4
,
4
,
ScalarT
>
const
&
m
);
// requires tg.hh
[[
nodiscard
]]
bool
operator
==
(
frustum
const
&
rhs
)
const
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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