17# pragma GCC diagnostic push
18# pragma GCC diagnostic ignored "-Wpedantic"
21# pragma clang diagnostic push
22# pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
23# pragma clang diagnostic ignored "-Wnested-anon-types"
26#include <vsg/maths/sphere.h>
53 value{0.0, 0.0, 0.0, 0.0} {}
61 value{
v[0],
v[1],
v[2],
v[3]} {}
67 value{normal.x, normal.y, normal.z,
in_p} {}
70 value{normal.x, normal.y, normal.z, -dot(position, normal)} {}
74 value{
v[0],
v[1],
v[2],
v[3]} {}
78 value{
v[0],
v[1],
v[2],
v[3]} {}
80 constexpr std::size_t size()
const {
return 4; }
82 value_type& operator[](std::size_t
i) {
return value[
i]; }
83 value_type operator[](std::size_t
i)
const {
return value[
i]; }
88 value[0] =
static_cast<value_type
>(
rhs[0]);
89 value[1] =
static_cast<value_type
>(
rhs[1]);
90 value[2] =
static_cast<value_type
>(
rhs[2]);
91 value[3] =
static_cast<value_type
>(
rhs[3]);
103 bool valid()
const {
return n.x != 0.0 && n.y != 0.0 && n.z != 0.0; }
105 explicit operator bool()
const noexcept {
return valid(); }
107 T* data() {
return value; }
108 const T* data()
const {
return value; }
124 constexpr bool operator!=(
const t_plane<T>& lhs,
const t_plane<T>& rhs)
126 return lhs[0] != rhs[0] || lhs[1] != rhs[1] || lhs[2] != rhs[2] || lhs[3] != rhs[3];
130 constexpr bool operator<(
const t_plane<T>& lhs,
const t_plane<T>& rhs)
132 if (lhs[0] < rhs[0])
return true;
133 if (lhs[0] > rhs[0])
return false;
134 if (lhs[1] < rhs[1])
return true;
135 if (lhs[1] > rhs[1])
return false;
136 if (lhs[2] < rhs[2])
return true;
137 if (lhs[2] > rhs[2])
return false;
138 return lhs[3] < rhs[3];
142 constexpr T distance(
const t_plane<T>& pl,
const t_vec3<T>& v)
144 return dot(pl.n, v) + pl.p;
147 template<
typename T,
typename R>
148 constexpr T distance(
const t_plane<T>& pl,
const t_vec3<R>& v)
150 using normal_type =
typename t_plane<T>::normal_type;
151 return dot(pl.n, normal_type(v)) + pl.p;
155 template<
class PlaneItr,
typename T>
156 constexpr bool intersect(PlaneItr first, PlaneItr last,
const t_sphere<T>& s)
158 auto negative_radius = -s.radius;
159 for (
auto itr = first; itr != last; ++itr)
161 if (distance(*itr, s.center) < negative_radius)
return false;
166 template<
class Polytope,
typename T>
167 constexpr bool intersect(
const Polytope& polytope,
const t_sphere<T>& s)
169 return intersect(polytope.begin(), polytope.end(), s);
173#if defined(__clang__)
174# pragma clang diagnostic pop
177# pragma GCC diagnostic pop
std container adapter for allocating with MEMORY_AFFINITY_NODES
Definition Allocator.h:138