25template<
typename T,
int Size>
28 const T &epsilon_factor)
30 for (
int i = 0; i < Size; i++) {
31 const float epsilon = epsilon_factor *
math::abs(a[i]);
42 for (
int i = 0; i < Size; i++) {
43 result[i] = a[i] >= 0 ? a[i] : -a[i];
51template<
typename T,
int Size>
57template<
typename T,
int Size>
63template<
typename T,
int Size>
69template<
typename T,
int Size>
75 for (
int i = 0; i < Size; i++) {
81template<
typename T,
int Size>
85 for (
int i = 0; i < Size; i++) {
91template<
typename T,
int Size>
98template<
typename T,
int Size>
102 for (
int i = 0; i < Size; i++) {
108template<
typename T,
int Size>
114template<
typename T,
int Size>
119 for (
int i = 0; i < Size; i++) {
128template<
typename T,
int Size>
138template<
typename T,
int Size>
145 for (
int i = 0; i < Size; i++) {
155template<
typename T,
int Size>
159 for (
int i = 0; i < Size; i++) {
169template<
typename T,
int Size>
176template<
typename T,
int Size>
193template<
typename T,
int Size>
198 for (
int i = 0; i < Size; i++) {
201 result[i] = ((a[i] +
b[i] - 1) /
b[i]) *
b[i];
210template<
typename T,
int Size>
215 for (
int i = 0; i < Size; i++) {
218 result[i] = (a[i] +
b[i] - 1) /
b[i];
223template<
typename T,
int Size>
233template<
typename T,
int Size>
243template<
typename T,
int Size>
249template<
typename T,
int Size>
255template<
typename T,
int Size>
261template<
typename T,
int Size>
271template<
typename T,
int Size>
281template<
typename T,
int Size>
285 for (
int i = 0; i < Size; i++) {
286 result[i] = a[i] >=
T(0) ? math ::sqrt(a[i]) :
T(0);
304template<
typename T,
int Size>
310template<
typename T,
int Size>
322template<
typename T,
int Size>
326 for (
int i = 1; i < Size; i++) {
338 for (
int i = 1; i < Size; i++) {
365template<
typename T,
int Size>
371template<
typename T,
int Size>
377template<
typename T,
int Size>
383template<
typename T,
int Size>
388 return incident - 2.0 *
dot(normal, incident) * normal;
391template<
typename T,
int Size>
396 float dot_ni =
dot(normal, incident);
397 float k = 1.0f - eta * eta * (1.0f - dot_ni * dot_ni);
401 return eta * incident - (eta * dot_ni +
sqrt(k)) * normal;
408template<
typename T,
int Size>
415 return v_proj * (
dot(p, v_proj) /
dot(v_proj, v_proj));
418template<
typename T,
int Size>
424 constexpr T threshold = std::is_same_v<T, double> ? 1.0e-70 : 1.0e-35f;
425 if (out_length > threshold) {
426 out_length =
sqrt(out_length);
427 return v / out_length;
434template<
typename T,
int Size>
452 return {a.y *
b.z - a.z *
b.y, a.z *
b.x - a.x *
b.z, a.x *
b.y - a.y *
b.x};
461 return {
float(
double(a.y) *
double(
b.z) -
double(a.z) *
double(
b.y)),
462 float(
double(a.z) *
double(
b.x) -
double(a.x) *
double(
b.z)),
463 float(
double(a.x) *
double(
b.y) -
double(a.y) *
double(
b.x))};
474 int nv =
int(poly.size());
481 for (
int i = 0; i < nv;) {
482 n[0] = n[0] + ((*v_prev)[1] - (*v_curr)[1]) * ((*v_prev)[2] + (*v_curr)[2]);
483 n[1] = n[1] + ((*v_prev)[2] - (*v_curr)[2]) * ((*v_prev)[0] + (*v_curr)[0]);
484 n[2] = n[2] + ((*v_prev)[0] - (*v_curr)[0]) * ((*v_prev)[1] + (*v_curr)[1]);
523template<
typename T,
typename FactorT,
int Size>
528 return a * (1 - t) +
b * t;
534template<
typename T,
int Size>
538 return (a +
b) * 0.5;
544template<
typename T,
int Size>
558 return ((
b.x >
b.y) ? ((
b.x >
b.z) ? 0 : 2) : ((
b.y >
b.z) ? 1 : 2));
567 for (
int i = 1; i < Size; i++) {
581 for (
int i = 1; i < Size; i++) {
595 for (
int i = 1; i < Size; i++) {
607 for (
int i = 1; i < Size; i++) {
631 return {-
v.y -
v.z,
v.x,
v.x};
633 return {
v.y, -
v.x -
v.z,
v.y};
635 return {
v.z,
v.z, -
v.x -
v.y};
652template<
typename T,
int Size>
655 const T epsilon =
T(0))
657 for (
int i = 0; i < Size; i++) {
671template<
typename T,
int Size>
674 for (
int i = 0; i < Size; i++) {
687 for (
int i = 0; i < Size; i++) {
699template<
typename T,
int Size>
701 const T epsilon =
T(10) * std::numeric_limits<T>::epsilon())
719template<
typename T,
int Size>
#define BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC(op, a, b)
#define BLI_UNROLL_MATH_VEC_OP_VEC(op, a)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
T length_squared(const VecBase< T, Size > &a)
VecBase< T, 3 > normal_tri(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
T pow(const T &x, const T &power)
T clamp(const T &a, const T &min, const T &max)
bool is_any_zero(const T &a)
T safe_divide(const T &a, const T &b)
VecBase< T, Size > project(const VecBase< T, Size > &p, const VecBase< T, Size > &v_proj)
T reduce_max(const VecBase< T, Size > &a)
isect_result< VecBase< T, Size > > isect_seg_seg(const VecBase< T, Size > &v1, const VecBase< T, Size > &v2, const VecBase< T, Size > &v3, const VecBase< T, Size > &v4)
T distance(const T &a, const T &b)
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T length(const VecBase< T, Size > &a)
VecBase< float, 3 > cross_high_precision(const VecBase< float, 3 > &a, const VecBase< float, 3 > &b)
QuaternionBase< T > normalize_and_get_length(const QuaternionBase< T > &q, T &out_length)
bool is_unit_scale(const MatBase< T, NumCol, NumRow > &m)
T length_manhattan(const VecBase< T, Size > &a)
T reduce_min(const VecBase< T, Size > &a)
T average(const VecBase< T, Size > &a)
T min(const T &a, const T &b)
T step(const T &edge, const T &value)
T midpoint(const T &a, const T &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
T safe_mod(const T &a, const T &b)
T interpolate(const T &a, const T &b, const FactorT &t)
VecBase< T, 3 > cross_tri(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
void min_max(const T &value, T &min, T &max)
T reduce_mul(const VecBase< T, Size > &a)
VecBase< T, Size > refract(const VecBase< T, Size > &incident, const VecBase< T, Size > &normal, const T &eta)
VecBase< T, Size > faceforward(const VecBase< T, Size > &vector, const VecBase< T, Size > &incident, const VecBase< T, Size > &reference)
bool almost_equal_relative(const VecBase< T, Size > &a, const VecBase< T, Size > &b, const T &epsilon_factor)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T distance_manhattan(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
bool is_equal(const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, const T epsilon=T(0))
VecBase< T, 3 > orthogonal(const VecBase< T, 3 > &v)
int dominant_axis(const VecBase< T, 3 > &a)
VecBase< T, Size > reflect(const VecBase< T, Size > &incident, const VecBase< T, Size > &normal)
VecBase< T, Size > ceil_to_multiple(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T max(const T &a, const T &b)
T mod(const T &a, const T &b)
bool is_unit(const VecBase< T, Size > &a, const T epsilon=T(10) *std::numeric_limits< T >::epsilon())
VecBase< T, 3 > cross_poly(Span< VecBase< T, 3 > > poly)
T reduce_add(const VecBase< T, Size > &a)
VecBase< T, Size > safe_sqrt(const VecBase< T, Size > &a)
enum blender::math::isect_result::@044052056044324103344077076162031251105165205056 kind